save generated page as htm on server

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!

Moderator: General Moderators

Post Reply
janper
Forum Newbie
Posts: 6
Joined: Wed Jun 02, 2010 5:55 pm

save generated page as htm on server

Post by janper »

hello
is it possible to save the html generated using php on server for further use? it takes about 10 seconds to generate my website using php and the result is generally allways the same until i don't upload something on the server. so it would be enough to generate the output let's say once a day an for the rest of the day use the static generated html.
i can imagine writing everything into a single string or so, but the site is already done and quite complex. i don't think i could now simply rewrite completely without forgetting something, so i'd like to use the already generated output.
maybe if it was possible to redirect the outuput into a file instead of the client browser?

thanks!

ps: the website is www.janper.sk
lunarnet76
Forum Commoner
Posts: 67
Joined: Sun Apr 04, 2010 2:07 pm
Location: Edinburgh

Re: save generated page as htm on server

Post by lunarnet76 »

hi,

You should be able to use

Code: Select all

// check if the output exists in cache
if(true){
// read the output
exit;
}
ob_start();
at the begining of your script then

Code: Select all

$content=ob_get_content();
// write content to a specific file name
janper
Forum Newbie
Posts: 6
Joined: Wed Jun 02, 2010 5:55 pm

Re: save generated page as htm on server

Post by janper »

thanks! it works ;)
Post Reply