Saturday 27 June 2015

Display source code of web pages

This is from the PHP manual, using the file function to display the source code of any URL. This is fun to play around with, and the basic file functionality I’ve used on a number of projects. Phun stuph! :)
 
 
<?php 
 
// display source code
$lines = file('http://google.com/'); // pick teh url
foreach ($lines as $line_num => $line) {
 // loop thru each line and prepend line numbers
 echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}
?> 

0 comments:

Post a Comment