Torflu Posted July 31, 2009 Share Posted July 31, 2009 Hey, I am trying to retrieve a source code,of a site,using file_get_contents.The simple code i am using is <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); $file = file_get_contents("http://xxxx.org/index.php"); echo $file; ?> But in my editor,the output is the website,not the source.Can anyone please suggest me where am i wrong and what should be the right code ? Link to comment https://forums.phpfreaks.com/topic/168264-solved-trying-to-retrive-source-code-of-a-website/ Share on other sites More sharing options...
GingerRobot Posted July 31, 2009 Share Posted July 31, 2009 But in my editor,the output is the website,not the source.Can anyone please suggest me where am i wrong and what should be the right code ? Which is correct. You're fetching a website's source code and displaying it in a browser. Thus the page is rendered exactly as it is on the original site. Run the $file through the htmlentities function before outputting to the brower to see the source code. This will convert all special HTML characters to the equivlant codes, preventing the browser from interpreting their special meaning. Link to comment https://forums.phpfreaks.com/topic/168264-solved-trying-to-retrive-source-code-of-a-website/#findComment-887493 Share on other sites More sharing options...
Torflu Posted July 31, 2009 Author Share Posted July 31, 2009 Thankyou,that solved my problem. Link to comment https://forums.phpfreaks.com/topic/168264-solved-trying-to-retrive-source-code-of-a-website/#findComment-887496 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.