Thursday 21 April 2016

PHP function to get source of webpage

Simple php function to get and display source code of a webpage.
function getSourceCode($pageurl) {
     $lines = file($pageurl);
     $output = "";
     foreach ($lines as $line_num => $line) {
         // loop thru each line and prepend line numbers
         $output.= "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
     }
}

No comments:

Post a Comment