Skip to content

Instantly share code, notes, and snippets.

@abbotto
Created October 26, 2012 16:00
Show Gist options
  • Save abbotto/3959607 to your computer and use it in GitHub Desktop.
Save abbotto/3959607 to your computer and use it in GitHub Desktop.
Display the source code of a webpage.
<?
// Want to be able to display the source code of any webpage, with line numbering? Here is a simple code snippet to do it. Just modify the url on line 2 or make a function.
$lines = file('http://google.com/');
foreach ($lines as $line_num => $line) {
// loop thru each line and prepend line numbers
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment