Jump to content

[SOLVED] Trying to retrive source code of a website.


Torflu

Recommended Posts

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 ?

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.

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.