Display Page Source - Server PHP Version

Use this app to display web page source code on any domain.

Enter address of web page:



Source code for pagesource.html [this page]

<!DOCTYPE html>
<html>
<head>
<title>Display Page Source</title>
</head>

<body>

<h2>Display Page Source - Server PHP Version</h2>
<p>
Use this app to display web page source code on any domain.
<form action="pagesource.php" method="post">
Enter address of web page:<br>
<input type="text" name="url" size="50"><br><br>
<input type="submit">
</form>
</p>

</body>
</html>

Source code for pagesource.php

<?php

if(strlen($_POST["url"]) > 0) {
    $address = $_POST["url"];
} else {
    $address = $_GET["url"];
}
 
if(strpos($address, "http://") !== 0 && strpos($address, "https://") !== 0) {
    $address = "http://" . $address;
}

$rawSource = file_get_contents($address);

highlight_string($rawSource);

?>