ravix76 Posted July 14, 2007 Share Posted July 14, 2007 I've created a dynamic site using PHP and MYSQL which is working great. To save server load, I have an admin feature that dumps all the pages (static) to HTML for browsing. However, on the dynamic site, I have a php include with checks IP Address and records a hit if it is unique. As the HTML dumping simply reads the source of the outputted dynamic page and dumps to HTML, the IP Addresd feature doesn't work. Is there a way to call a PHP Include from HTML or do I need to dump all the static pages to php instead? Thanks Link to comment https://forums.phpfreaks.com/topic/59961-solved-php-from-html/ Share on other sites More sharing options...
redarrow Posted July 14, 2007 Share Posted July 14, 2007 any php code using an include function will need to be used on a .php page to work. this is not true if a programmer sets the php.ini for .html file to work for php. Link to comment https://forums.phpfreaks.com/topic/59961-solved-php-from-html/#findComment-298196 Share on other sites More sharing options...
ravix76 Posted July 14, 2007 Author Share Posted July 14, 2007 Ok. I'm now outputting static files to filename.php using the following... $staticpagedata = file_get_contents($sourcepage); and then writing to a file. Thus $staticpagedata contains the outputted source of the page and not the dynamic source eg <-- Stats Start--> Static PHP outputted to browser (ie not dynamic) <--Stats End--> What I then want to do is replace all data in the $staticpagedata between "<--Stats Start-->" and "<--Stats End-->" with "<?php virtual('/stats.php'); ?>" In Summary Is there an easy way to cut / replace "EFG" from string "ABCDEFGHIJ" when you know point "D" and "H" but EFG might not always be EFG.... ie I can't use "Str_replace" because I don't know what I'll be replacing" erm... hope that makes sense! Many thanks! Link to comment https://forums.phpfreaks.com/topic/59961-solved-php-from-html/#findComment-298271 Share on other sites More sharing options...
ravix76 Posted July 14, 2007 Author Share Posted July 14, 2007 Different thought! I've put term [sTATS] into the dynamic page and thus can str_replace it with "<?php virtual('/phpincs/stats.php'); ?>" Link to comment https://forums.phpfreaks.com/topic/59961-solved-php-from-html/#findComment-298330 Share on other sites More sharing options...
uramagget Posted July 14, 2007 Share Posted July 14, 2007 It'd make partially no sense to map PHP to work for HTML files, because then it'd add a little extra load to your server for every HTML file. I think it's just a good idea to let PHP map to it's proper extensions (phtml, php, php3, etc.) Link to comment https://forums.phpfreaks.com/topic/59961-solved-php-from-html/#findComment-298332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.