Re: Creating an Entire .html page with PHP
| From: | dealtek | Date: | Wed, 27 Jan 2010 18:21:00 +0000 |
| Subject: | Re: Creating an Entire .html page with PHP | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301570@lists.php.net to get a copy of this message | ||
On 1/26/2010 6:08 PM, clancy_1@cybec.com.au wrote:
In principle this is extremely simple. Take your existing procedure to generate the page then: 1. $page = ''; 2. Replace every echo 'whatever'; statement with $page .= 'whatever';, and every<html> with $page .= '<html>'; 3. file_put_contents($page,$file) // The manual is down (again!) and I have forgotten the format. 4. echo( file_get_contents($file)); // to generate the PHP page. However I strongly suspect that it is possible to simply redirect all the 'echo's in your existing procedure to write to $page (or $file?), without changing the code at all. Is this so? Thanks Clancy for the details - much appreciated,Actually I would like to use BOTH techniques. If it's possible to take an exsisting page and just save that (without all the rewriting ) that would also be great... As an example, say you had a details master dynamic php page to display let's say a product (pulled from the database from url ID=334 or whatever) If I also wanted to create a STATIC .html page from that for just this one product - it would be great to be able to this too. Part of the reason for this is as Ashley mentioned: SEO Another thing I'm trying to do is create some admin pages - where a user can type in some text and choices - and hard coded .html pages go on the site. Thanks for the help