• 0

[PHP] save generated PHP page as a static HTML file?


Question

Hi guys,

I have a dynamic php page that pulls data from a mysql database. I want to save the generated php page to a static html page so the content doesn't update when the database gets updated. I am having a lot of problems with this. Anybody have any clue on how to do this? Thanks!!!!!!!

5 answers to this question

Recommended Posts

  • 0

Hi!

If you just want to save a .html file, most web browsers have a "Save As..." feature within the "File" menu that will allow you to save what you are looking at in a .html format.

Is this something you want to automate? As in, perhaps, creating a cache file for database results to reduce the number of database hits? I usually collect my output into a really large string variable. You then have the option to output that to the client, or use some of the PHP functions to save that output to disk (or both). You could, for instance, use the variables that land in the WHERE part of your SQL statement and produce a file name that is checked for. If the file name is found, just output that to the client. If it isn't found, generate the file (hit the database) and then output to the client.

  • 0
  _tux_ said:
I think what your looking for it output buffering (http://us3.php.net/manual/en/book.outcontrol.php)

you could turn buffering on, do your page rendering, and save the result of ob_get_contents into a file

(Y)

Clickable link for the lazy: http://us3.php.net/manual/en/book.outcontrol.php

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.