Re: Creating an Entire .html page with PHP
| From: | clancy_1 at cybec dot com dot au | Date: | Wed, 27 Jan 2010 02:08:48 +0000 |
| Subject: | Re: Creating an Entire .html page with PHP | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301513@lists.php.net to get a copy of this message | ||
On Mon, 25 Jan 2010 18:31:54 -0800, dealtek@gmail.com ("dealtek@gmail.com") wrote:
>
>On Jan 25, 2010, at 6:23 PM, Shawn McKenzie wrote:
>
>> file_put_contents() is soooo much easier.
>
>Thanks Shawn I'll check that out ...
>
>- I see it says : This function is identical to calling fopen(),
>fwrite() and fclose() successively to write data to a file.
>
>
>my newbie brain likes that!
>
>
>Thanks,
>dealtek@gmail.com
>[db-10]
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?