Results 1 to 3 of 3
Sep 29, 2009, 14:30 #1
Creating Static html pages from dynamic php content???
Here's my problem:
I am trying to create a new shopping cart system that will create static .html pages from my php generated pages. So that I don't have to query the database everytime information is requested. Such as a Product information sheet.
Here is the current code I've been working with, but when I view the new generated file, the php code is still there. Not the generated HTML.
<?php ob_start(); // start trapping output $myFile = "templates/temp1.php"; $staticpage = file_get_contents($myFile); echo $staticpage; $output = ob_get_contents(); // get contents of output //write to file, e.g. $newfile="default.html"; $file = fopen ($newfile, "w"); fwrite($file, $output); fclose ($file); ob_end_clean(); // discard output ?>You know you cooler than me...
Sep 29, 2009, 15:05 #2
- Join Date
- Feb 2008
- 0 Post(s)
- 0 Thread(s)
Instead of the above, why don't you use some reliable PHP caching system? Caching systems are exactly for purposes like the one you're describing. Two obvious choices:
Sep 30, 2009, 14:05 #3
I seem to of found this which only displays the html output without including the php in the page.
<?php $cacheFile = file_get_contents('https://fieldsimc.com/optimization/processkeys.php?link=&keywordsearch='); ob_start(); // write content echo $cacheFile; $content = ob_get_contents(); ob_end_clean(); file_put_contents("ztest.php",$content); echo $content; ?>You know you cooler than me...