I want to duplicate one of my web pages to a different URL, but I want it copied AFTER all of the PHP includes have finished running on the page. Here is what I have so far, but of course it just copies the source code of the page and not resulting page AFTER all PHP includes have run.
The page I want to copy has 90 different data insertions using PHP includes so if course it loads really slow. So I want to copy the FINISHED page after all 90 includes are done loading.
This is what I tried first:
<?php
$source =file_get_contents('web-page.htm');
$destination = 'new-web-page.htm';
$handle = fopen($destination, "w");
fwrite($handle, $source);
fclose($handle);
?>
Here is an example of one of the 90 different PHP includes on the original page:
<?php include 'data.txt';?>
OK - I solved it this way:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.com/example.htm");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
$destination = 'new-page-after-all-php-and-javascript-has-run.htm';
$data = $result;
$handle = fopen($destination, "w");
fwrite($handle, $data);
fclose($handle);
?>