Re: Static HTML using PHP
From: Harrie Verveer (nospamplease_at_remove_this_part_and_the_first_dot_in_the_domain_name_harrie.verve)
Date: 11/29/04
- Next message: Neal: "Re: strict.dtd??"
- Previous message: Matt Smyth: "Static HTML using PHP"
- In reply to: Matt Smyth: "Static HTML using PHP"
- Next in thread: Peter: "Re: Static HTML using PHP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Nov 2004 23:52:46 +0100
Hi Matt,
you can do this by, instead of outputting your HTML code, catching it
into a string, and when done parsing spit the HTML code into a file
(when you add an article). If you want to be really evil you could
override the echo() function (never tried that by the way) or catch the
output buffer with ob_start() etc. Last options are really nasty. Nicest
way still is to simply output everything into a string (or get the
string from a template engine - yeah! :D), you'll find this very easy to
do when you get into OO-php-programming.
don't worry about someone viewing the site while the file is written -
the box your site is running on is probably linux, and it will prevent
strange things to happen - and besides that, writing the file shouldn't
take much more than about 1/1000 sec.
It's a great way of reducing serverload and loading times by using this
kind of caching by the way! (I think more people should embrase caching).
Good luck with the project, keep us informed!
Harrie
Matt Smyth wrote:
> I'm creating a website with a blog type front page. When a new article
> is submitted into the database, I want to create a static html file for
> the front-page-articles instead of dynamicly generating them each time
> the home page loads. How would I do this so there are no conflicts. for
> example: if the file is being generated(is there a way to lock anyone
> else from using it), I want any code trying to access it to wait(if data
> is being written) until it is done. Basically, if the file is being
> written and someone tries to read the page, the user doesn't get and
> error or incomplete file.
>
> Thanks,
>
> Matt
- Next message: Neal: "Re: strict.dtd??"
- Previous message: Matt Smyth: "Static HTML using PHP"
- In reply to: Matt Smyth: "Static HTML using PHP"
- Next in thread: Peter: "Re: Static HTML using PHP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|