PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need to do a simple thing. There is a PHP script that creates some output dynamically. Now I want to create a static version of the same page - e.g. update.php = dynamic, update.html = static.
This works. But only if this code is executed from a different file - i.e. not from update.php itself. Is there a way to make it work correctly from the same file? Technically, it does work but for some reason it seems to loop several times.
It's 3 AM local time so only some clear ideas please
I need to do a simple thing. There is a PHP script that creates some output dynamically. Now I want to create a static version of the same page - e.g. update.php = dynamic, update.html = static.
This works. But only if this code is executed from a different file - i.e. not from update.php itself. Is there a way to make it work correctly from the same file? Technically, it does work but for some reason it seems to loop several times.
It's 3 AM local time so only some clear ideas please
Thanks!
Tomas
If you include the copy function in the same file, you are making a recursive page, so once it enters and executes copy(), the file is processed again and copy is called again, and again...
To solve this, the best way is not to call copy from the update.php
A not very good solution () :
Your code does work but since it's a dynamic php code, it has to be accessed through the http protocol to make the static output. And when you change it to that, we are back to the "loop" problem.
<?php
// very top of script
ob_start();
echo 'foo';
?>
<html>
more foo
<?php
// very bottom of script
$output = ob_get_contents();
// now write $output to a file
?>