Re: Creating an Entire .html page with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@xxxxxxxxx (dealtek) wrote:

>On 1/26/2010 6:08 PM, clancy_1@xxxxxxxxxxxx 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...

Dead easy. View the page - any page - in your browser.  Then (in Explorer) View>Source.
This will put up the HTML in the default viewer (preferably notepad; word would mess it
up).  Then save it from notepad as whatever.htm, and you can do what you like with it.
Links to images, etc, will be saved in their original form, and will continue to work in
the replica page as long as the original image is in the specified location.

This would probably be the simplest solution for your original question -- much simpler
than modifying the source code, or redirecting the output.

It is also an excellent (in my opinion almost essential) method of doing a sanity check on
any new page design, especially if it is at all complicated. On a number of occasions I
have discovered PHP diagnostics hidden in the HTML which don't appear on the screen at
all, and it is amazing how badly the HTML can be off without disrupting the screen
appearance. Opening tables, etc, wrongly generally messes the page up completely, but
forgetting to close them again often has no affect no visible effect at all -- until you
make some innocent change and everything goes haywire!

>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.

I'm not sure why your emphasis on the static .html page -- it doesn't seem necessary --
but what you are describing is somewhat like my new engine, which is used in the page
www.corybas.com. This effectively incorporates a database, although all the data is stored
in simple text files. It only has one page, but this can be modified to do wildly
different things by specifying different parameters.

The Engine has an address book/mail merge facility which is far more useful (and far
quicker)  than Microsoft's monstrosities, but this is not on show because I would have to
generate a large list of bogus people to demonstrate it.

It also has good facilities for editing the data files, but these again are difficult to
demonstrate publicly.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux