Jump to content

View the source of another page


kevloink

Recommended Posts

i tried to edit my post, but the time to edit had expired. I got that code from the php docs on php.net. I was hoping to figure out a way to leaving in the whitespace, so that the html looks nicer when displayed, but I haven't figured it out.

Also keep in mind the PHP files your accessing are post-parsed. Any PHP in the file will return just as plain HTML since PHP is operated server side.

 

And yeah I also think your looking for nl2br() but just incase that doesn't work keep in mind you can always cheat and do something like

 

$file = str_replace( " ", "<WHITE>", $file );

 

process your file

 

$file = str_replace ( "<WHITE>", " ", $file );

 

This basically transforms the white space to data PHP won't touch, then transforms it back again. Haven't tested it, but I don't see why it wouldn't work.

I couldn't figure out how to do it with file_get_contents() and still have the appropriate whitespace and line breaks. I did however provide a good solution to the original question, so maybe somebody else can come up with another way or a better way and share. I'm still a php newbie!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.