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 ? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Torflu Posted July 31, 2009 Author Share Posted July 31, 2009 Thankyou,that solved my problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.