Use PHP to Save Webpage Content on the same URL
<p>I need to use PHP to save a webpage which has content generated in an iFrame, Its like this..</p>

<p>I have a .PHP file with an iFrame (inside which it opens a URL which produces dynamic content) inside it.</p>

<p>I want the Php file to save the generated content (or the whole source) to the server.</p>

<p>I tried the @file_get_contents but how do I specify the URL of the same .php file since it is in iFrame..?</p>

<p>Also how can I output the entire HTTP header into a file with PHP?</p>

<p>I know its a bit unclear but bear with me please!</p>

<p>I tried this code but it doesn't work.</p>

<p>CODE</p>

<pre><code>&lt;html&gt;
&lt;body&gt;
&lt;?php

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
$contents = @file_get_contents($pageURL);
$fp = fopen("file.txt", "a");
fputs($fp, "
$contents
");
fclose($fp);
?&gt;
&lt;iframe src="LINK TO WEBPAGE HERE" /&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Thanks</p>
