Here is the PHP code to fetch the html source code of any website specified. fopen function is used to open the website URL. stream_get_contents is used to read the opened URL. The fetched code is displayed inside a textarea.
$domain = 'http://example.com';
$handle = fopen($domain, 'r');
$content = stream_get_contents($handle);
/**
// alternative to stream_get_contents
$contents = '';
while (!feof($handle)) {
$content .= fread($handle, 8192);
}
**/
fclose($handle);
/**
* print html content on textarea
*/
echo "<textarea rows='20' cols='80'>$content</textarea>";
Hope it helps.
Thanks.