Re: Static Pages with PHP

From: Date: Mon, 20 Nov 2006 22:18:24 +0000
Subject: Re: Static Pages with PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-244900@lists.php.net to get a copy of this message
On Sun, November 19, 2006 11:41 pm, Paul Novitski wrote: > a) You can redirect to the static page. It can have either an .html > extension or a .php extension. If all it contains is HTML markup, > that's what will be downloaded to the client. > > http://php.net/header > header("Location: http://www.example.com/"); Rant #37: This chews up an HTTP connect, adds significant network "lag" to the client-server interaction, and ends up reading the static file you could have just read in your original script. It will "work" but is, imho, a needless waste of resources and more confusing/complicated than a simple readfile() > b) You can read the HTML markup from a separate file and echo it to > the client. (e.g., file(), get_file_contents()) > > http://php.net/file_get_contents > echo file_get_contents('example.html'); This will read the file into RAM, then into a PHP string, then echo it out. I *think* readfile() will, at least in later versions, be more efficient. Not that it really matters for performance to most users, but, still, readfile() is probably more clear to read. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#244900) next »