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


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



Relevant Pages

  • Re: CGI C and HTML
    ... > Consider this HTML code. ... > Does't interest to tokenize and to unescape the string. ... prog2 and prog3 that all read from stdin and write to stdout then on ...
    (comp.lang.c)
  • Re: Web Form acts differently when using C# than VB
    ... The value of "SomeKey" is not a string. ... > I have a sample web form in C# that works correctly. ... > Part of the VB HTML code looks like this: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: [VB.NET express 2005] - Regular expressions
    ... Private Function findImgTags(ByVal strHTML As String) As Object ... Dim str As Object ... while if you meant html code, well imagine an html page with a serie of ... I would like to retrieve just the last one. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: mail
    ... >>HTML code in the string $message that you put into the mailfunction. ... >>impossible unless a clients computer is specifically set up to execute PHP ... >>Express and Firefox both install default with JScript and Java turned off. ... The body of an email is a string. ...
    (comp.lang.php)