techfolks php tutorials logo
code to get source code of a website html code of a web page in php html code of any webpage PHP reading the source code of a webpage Sample Programs source code viewer UseFul Functions web page source code

How to Get Source Code of a Web Page


If you are looking for How to Get Source Code of a Web Page or link then just follow below steps.

How To Find A Web Page’s Source Code it easy?

Source Code of a Web Page

By using below PHP function you can easily get the source code of a web page, Source code printed is in HTML.

Source Code of a Web Page in PHP

<?php

$pageurl = "https://www.techfolks.net";

$sourceCode = showSourceCode($url);

echo $sourceCode;

?&gt;</pre>

function showSourceCode($pageurl)
{

$lines = file($pageurl);

$op = "";

foreach ($lines as $lineno =&gt; $line) {

// loop thru each line and add line numbers

$output.= "Line #<strong>{$lineno}</strong> : " . htmlspecialchars($line) . "
n";

}

}

?>

Leave a Reply

Your email address will not be published. Required fields are marked *