HTML source into PHP

I would like to be able to retrieve the actual source of a HTML file from my own web server via php is this possible?

This you can also put in youre php page orcourse

<!-- Begin
function viewSource() {
document.getSource.view.value="Please wait!";
setTimeout("document.getSource.view.value='View Source!'",6000);
window.location.href= "view-source:" + document.getSource.url.value;
return false;
//  End -->

<!-- put this within youre <body> -->


Type in a full URL and click "View Source"
<form name=getSource onSubmit="return viewSource();">
<input type=text name=url value="http://">
<input type=submit name=view value="View Source">

Well realistically I am looking for a way to be able to call a PHP script that will echo back the HTML of a page on my server so I can view it and update it. So maybe I should have been more specific…also, btw I couldn’t get that script to work. You can check it out it does nothing and I cut and pasted your code :frowning:



Add that before
<-- Begin

put it into php file:

<?php show_source(basename($_GET['url'])); ?>

and use it like



Didnt know that worked for html lol, never tried it either…

why can’t ya just gop up to veiw>source in ie and its in mozilla too


Signifer, that won’t work because it’ll show the HTML generated by the PHP script and not the actual PHP script.

Actually guys…I had to go to this code.

function ShowSourceXML($filename="",$wrap=true) {
 if (file_exists($filename)) {
	 show_source( $filename );
	 $t = ob_get_contents();
	 $source=explode("<br />",$t);
	 $final = '<?xml version="1.0" encoding="iso-8859-1"?><source>';
		foreach ($source as $line) {
			$final .= "<line lineNum='".$counter++."'><![CDATA[$line]]></line>";
	 $final .= "</source>";
  echo $final;
 } else {
  echo false;

That returns the sites HTML or PHP or XML data…in XML form…its sweeet. It is moded code from a site I found…It returned it as a HTML page with each line numbered…so I just changed a few things…thanks for all the help though!