ravix76 Posted February 24, 2007 Share Posted February 24, 2007 Hi, I'm trying to dump my PHP code to Static HTML and have followed this tutorial: http://www.phpfreaks.com/tutorials/29/4.php However, the static file is only partially complete which I suspect is due to the fread limit? I note at the bottom of that tutorial that a fellow user had the same problem but the links to the responses don't seem to work (probably as it's 3 years old!). Can anyone help me with a work around to get my PHP fully dumped? Thanks Ravix76 Link to comment https://forums.phpfreaks.com/topic/39957-solved-php-to-static-html/ Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 Post your php code and show us what you're working with: PHP CODE HERE Link to comment https://forums.phpfreaks.com/topic/39957-solved-php-to-static-html/#findComment-193196 Share on other sites More sharing options...
ravix76 Posted February 24, 2007 Author Share Posted February 24, 2007 It's pretty much identical to that in the tutorial: $url = "xxxx URL With-held xxxx"; $sourcepage = "$url/data/dynamicfiles/showproductpage.php?id=1"; $tempfilename = "../data/dynamicfiles/temp_suppfile.html"; $targetfilename = "../data/".$branddir.$productfilename.".html"; $dynamic_source = fopen($sourcepage, 'r'); if (!$dynamic_source) { echo "<strong>Unable to load $sourcepage - Static page! Update Failed!</strong>"; exit(); } $htmldata = fread($dynamic_source, 1280*1280); fclose($dynamic_source); $tempfile = fopen($tempfilename, 'w'); if (!$tempfile) { echo"<strong>Unable to open temporary file $tempfilename for writing! Static page update aborted!</strong>"; exit(); } fwrite($tempfile, $htmldata); fclose($tempfile); copy($tempfilename, $targetfilename); unlink($tempfilename); echo "<strong>Static HTML Page Built!</strong>"; It appears to run fine, but the source of the static page is incomplete, hence half the page is missing. Link to comment https://forums.phpfreaks.com/topic/39957-solved-php-to-static-html/#findComment-193212 Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 well here's the thing, I tested it on a page just now and it works fine for a short file like u said, so to truly understand the problem one would need to see the url you hid to see why exactly it is getting cut off and at what file size, etc.. Link to comment https://forums.phpfreaks.com/topic/39957-solved-php-to-static-html/#findComment-193232 Share on other sites More sharing options...
ravix76 Posted February 25, 2007 Author Share Posted February 25, 2007 After surfing around some more and reading the php manual some more, I've ditched the Fopen / Fread and used file_get_contents instead which is working perfectly. Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/39957-solved-php-to-static-html/#findComment-193334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.