Basically I'd like my dynamic php built pages to create a static .html copy of themselves as they are loaded, if a copy doesn't already exist.
I know how to check for a static copy before building the dynamic page.
I'm having trouble getting the current page to save properly however, any ideas?
Specifics: I'm using "file_get_contents($_SERVER['PHP_SELF']);" at the very bottom of the dynamic page code to try and get a copy of the current page into string form, is this just creating a never ending loop?
I'm also trying to save the .html file with the same url that the current page has which sounds like it shouldn't work but you have to remember that the current url doesn't exist. ie: example.com/big-red-widgets doesn't exist because it is actually example.com/dynamic-script.php with .htaccess help.
best effort...
<?php
$homepage = $_SERVER['PHP_SELF']
$homepageContent = file_get_contents($_SERVER['PHP_SELF']);
$fp=fopen($homepage,'w+');
fputs($fp,$homepageContent);
fclose($fp);
?>