Re: Creating an Entire .html page with PHP

Re: Creating an Entire .html page with PHP

am 26.01.2010 01:59:20 von Ashley Sheridan

--=-/wWo3nZHs+TB4Z1g+Job
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Mon, 2010-01-25 at 17:00 -0800, dealtek@gmail.com wrote:

> Hi Folks,
>
> I would like to create an entire .html page gathered from database
> content mixed with html etc. and be able to save the page...
>
>
> like:
>
> --- save all this pre made content as .html page....
>
>
>
> ... stuff
>
>
> ... stuff
> ... stuff with database query results...
> ... stuff
>
>
>
> Q: Is there a function that might help with saving the whole content
> as .html page?
>
>
>
> Thanks,
> dealtek@gmail.com
> [db-10]
>
>


$fh = fopen("page.html","w");
fwrite($fh, $htmlcode);


Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-/wWo3nZHs+TB4Z1g+Job--

Creating an Entire .html page with PHP

am 26.01.2010 02:00:42 von dealtek

Hi Folks,

I would like to create an entire .html page gathered from database
content mixed with html etc. and be able to save the page...


like:

--- save all this pre made content as .html page....



.... stuff


.... stuff
.... stuff with database query results...
.... stuff



Q: Is there a function that might help with saving the whole content
as .html page?



Thanks,
dealtek@gmail.com
[db-10]


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

Re: Creating an Entire .html page with PHP

am 26.01.2010 02:12:46 von Angus Mann

----- Original Message -----
From:
To: "PHP-General"
Sent: Tuesday, January 26, 2010 11:00 AM
Subject: [PHP] Creating an Entire .html page with PHP


> Hi Folks,
>
> I would like to create an entire .html page gathered from database
> content mixed with html etc. and be able to save the page...
>
>
> like:
>
> --- save all this pre made content as .html page....
>
>
>
> ... stuff
>
>
> ... stuff
> ... stuff with database query results...
> ... stuff
>
>
>
> Q: Is there a function that might help with saving the whole content as
> .html page?
>
>
>
> Thanks,
> dealtek@gmail.com
> [db-10]

Not really...no. The fact that you're asking this question makes me think
you should start with a less ambitious goal than you describe. Terms like
"saving the whole content as a .html page" and "content mixed with html" are
pretty meaningless, I'm afraid.

Try generating a few ordinary pages before you throw a database into the
mix.


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

Re: Creating an Entire .html page with PHP

am 26.01.2010 02:17:04 von Al

On 1/25/2010 8:00 PM, dealtek@gmail.com wrote:
> Hi Folks,
>
> I would like to create an entire .html page gathered from database
> content mixed with html etc. and be able to save the page...
>
>
> like:
>
> --- save all this pre made content as .html page....
>
>
>
> ... stuff
>
>
> ... stuff
> ... stuff with database query results...
> ... stuff
>
>
>
> Q: Is there a function that might help with saving the whole content as
> .html page?
>
>
>
> Thanks,
> dealtek@gmail.com
> [db-10]
>

rename(APPLIC_DB_FILE, APPLIC_DB_FILE . 'BAK'); //make a backup
$serTxt = serialize($dbTable);
if(!file_put_contents(APPLIC_DB_FILE, $serTxt, LOCK_EX))
die("

Major error in
upDateDBTable(). Contact tech support
");

$dbTable = unserialize(file_get_contents(APPLIC_DB_FILE)); //Current application
file



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

Re: Creating an Entire .html page with PHP

am 26.01.2010 03:17:54 von dealtek

On Jan 25, 2010, at 4:59 PM, Ashley Sheridan wrote:


>
> $fh = fopen("page.html","w");
> fwrite($fh, $htmlcode);
>
>
>

Thanks so much Ashley and ALL, this looks like it will work fine.

BTW: Sorry if I didn't make myself clear - I just wanted to grab some
data like a person from a contacts file and be able to save a
static .html web page with their data - etc.

.... this little test seems to work

I added fclose($fh); at the end (correct?)


- - - - - -



// got some data with query 'get'...

$addthis = ' my name is: ';

$fh = fopen("testpage.html","w");

$htmlcode = ' Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">



Untitled Document




this is a test

'.$addthis.'
'.$row_get['FirstName'].'
'.$row_get['LastName'].'


this is a test 2




';


fwrite($fh, $htmlcode);

fclose($fh);

?>





Thanks,
dealtek@gmail.com
[db-10]


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

Re: Creating an Entire .html page with PHP

am 26.01.2010 03:23:28 von Shawn McKenzie

dealtek@gmail.com wrote:
>
> On Jan 25, 2010, at 4:59 PM, Ashley Sheridan wrote:
>
>
>>
>> $fh = fopen("page.html","w");
>> fwrite($fh, $htmlcode);
>>
>>
>>
>
> Thanks so much Ashley and ALL, this looks like it will work fine.
>
> BTW: Sorry if I didn't make myself clear - I just wanted to grab some
> data like a person from a contacts file and be able to save a static
> .html web page with their data - etc.
>
> ... this little test seems to work
>
> I added fclose($fh); at the end (correct?)
>
>
> - - - - - -
>
>
> >
> // got some data with query 'get'...
>
> $addthis = ' my name is: ';
>
> $fh = fopen("testpage.html","w");
>
> $htmlcode = ' > Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
> Untitled Document
>
>
>
>
> this is a test

'.$addthis.'
'.$row_get['FirstName'].'
> '.$row_get['LastName'].'

>
> this is a test 2
>
>
>
>
> ';
>
>
> fwrite($fh, $htmlcode);
>
> fclose($fh);
>
> ?>
>
>
>
>
>
> Thanks,
> dealtek@gmail.com
> [db-10]
>

file_put_contents() is soooo much easier.

--
Thanks!
-Shawn
http://www.spidean.com

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

Re: Creating an Entire .html page with PHP

am 26.01.2010 03:31:54 von dealtek

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]


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

Re: Creating an Entire .html page with PHP

am 26.01.2010 15:55:54 von Ryan Sun

--001636ed629f979029047e127b65
Content-Type: text/plain; charset=ISO-8859-1

Isn't there a framework doing that?

On Mon, Jan 25, 2010 at 8:00 PM, dealtek@gmail.com wrote:

> Hi Folks,
>
> I would like to create an entire .html page gathered from database content
> mixed with html etc. and be able to save the page...
>
>
> like:
>
> --- save all this pre made content as .html page....
>
>
>
> ... stuff
>
>
> ... stuff
> ... stuff with database query results...
> ... stuff
>
>
>
> Q: Is there a function that might help with saving the whole content as
> .html page?
>
>
>
> Thanks,
> dealtek@gmail.com
> [db-10]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--001636ed629f979029047e127b65--

Re: Creating an Entire .html page with PHP

am 26.01.2010 16:04:13 von Ashley Sheridan

--=-u60wiu54+PC4Vu9ATaRr
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Tue, 2010-01-26 at 09:55 -0500, Ryan Sun wrote:

> Isn't there a framework doing that?
>
> On Mon, Jan 25, 2010 at 8:00 PM, dealtek@gmail.com wrote:
>
> > Hi Folks,
> >
> > I would like to create an entire .html page gathered from database content
> > mixed with html etc. and be able to save the page...
> >
> >
> > like:
> >
> > --- save all this pre made content as .html page....
> >
> >
> >
> > ... stuff
> >
> >
> > ... stuff
> > ... stuff with database query results...
> > ... stuff
> >
> >
> >
> > Q: Is there a function that might help with saving the whole content as
> > .html page?
> >
> >
> >
> > Thanks,
> > dealtek@gmail.com
> > [db-10]
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


I think generally though, it's usual to have the pages created and
output on the fly, rather than output the .html page. Some CMS's do
publish the .html pages, but unless the page is created from very
complex content, or your site is expecting a large amount of traffic,
there's not much use to do it. I've heard people mention SEO as a
reason, but I've not seen any evidence, and there are ways via
mod_rewrite to mask the actual content pages.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-u60wiu54+PC4Vu9ATaRr--

Re: Creating an Entire .html page with PHP

am 26.01.2010 16:45:04 von Michael Peters

Ashley Sheridan wrote:

>>>
>
>
> I think generally though, it's usual to have the pages created and
> output on the fly, rather than output the .html page.

Yes, though often using a cache if it is dynamic content that doesn't
change often. No reason to hit the db continuously if the content is the
same as when you hit it the last 278 times.

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

Re: Creating an Entire .html page with PHP

am 27.01.2010 03:08:48 von Clancy

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
with $page .= '';

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?

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

RE: Creating an Entire .html page with PHP

am 27.01.2010 03:52:06 von Daevid Vincent

> -----Original Message-----
> From: clancy_1@cybec.com.au [mailto:clancy_1@cybec.com.au]
> Sent: Tuesday, January 26, 2010 6:09 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Creating an Entire .html page with PHP
>
> 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
> with $page .= '';
>
> 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?

First of all writing pages in this old fashioned .cgi sort of way is so
1990's. Concatenating your whole page to a giant string is silly and
defeats the benefits (and purpose) of using PHP.
I'm actually in the process of porting a HUGE site from that style to a
more sane MVC and PHPish way right now. It makes me cringe every day I have
to look at 'old' code.

But instead of doing the above stuff, I suggest you look into this awesome
function.

http://us2.php.net/manual/en/function.ob-start.php

I use it to create a weekly email that can be displayed online and then use
another script to email said HTML email to users.

ob_start();
include "/home/foo/public_html/weekly_email.php";
$message = ob_get_contents();
ob_end_clean();

$message will not contain all the output that weekly_email.php had

Adapt as needed to 'render' your page and store it in your $page variable
if you absolutely must do that style of coding. ...and God help you, as
it's a nightmare to work with.

d


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

Re: Creating an Entire .html page with PHP

am 27.01.2010 07:09:59 von Clancy

On Tue, 26 Jan 2010 18:52:06 -0800, daevid@daevid.com ("Daevid Vincent") wrote:

.............

>First of all writing pages in this old fashioned .cgi sort of way is so
>1990's. Concatenating your whole page to a giant string is silly and
>defeats the benefits (and purpose) of using PHP.
>I'm actually in the process of porting a HUGE site from that style to a
>more sane MVC and PHPish way right now. It makes me cringe every day I have
>to look at 'old' code.

I suggest you read the question that started all this.

I don't know why you should want to store a compiled page, but someone asked how they
could do it, and I have suggested one way. PHP doesn't seem to have any problems with
long strings (file_put_contents & file_get_contents actually treat the contents as a
string, and they don't slow down till the length grows past ~100k), so if you did, this
would work as well as any other way.

And however you generate a web page, it is effectively sent to the browser as a string
(which can include linefeeds and all the rest) so this would work regardless of whatever
fancy tricks you used to generate it.

(And I don't open HTML e-mails if I can possibly avoid it.)

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

Re: Creating an Entire .html page with PHP

am 27.01.2010 19:21:00 von dealtek

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
> with $page .= '';
>
> 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

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

Re: Creating an Entire .html page with PHP

am 28.01.2010 00:31:56 von Clancy

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

>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
>> with $page .= '';
>>
>> 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

Re: Creating an Entire .html page with PHP

am 28.01.2010 21:10:42 von Rene Veerman

On Thu, Jan 28, 2010 at 12:31 AM, wrote:
> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
>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!

whenever i write an opening tag, i immediately write the closing tag
next, then cursor back to fill it in.

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

Re: Creating an Entire .html page with PHP

am 28.01.2010 22:17:34 von Clancy

On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:

>On Thu, Jan 28, 2010 at 12:31 AM, wrote:
>> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
>>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!
>
>whenever i write an opening tag, i immediately write the closing tag
>next, then cursor back to fill it in.

Not so easy when you are using PHP to generate a complex layout!


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

Re: Creating an Entire .html page with PHP

am 28.01.2010 22:23:05 von Paul M Foster

On Fri, Jan 29, 2010 at 08:17:34AM +1100, clancy_1@cybec.com.au wrote:

> On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:
>
> >On Thu, Jan 28, 2010 at 12:31 AM, wrote:
> >> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
> >>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!
> >
> >whenever i write an opening tag, i immediately write the closing tag
> >next, then cursor back to fill it in.
>
> Not so easy when you are using PHP to generate a complex layout!

Use heredocs to do it. Then you can generate the layout in PHP and still
do what dealtek@gmail.com said.

Paul

--
Paul M. Foster

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

Re: Creating an Entire .html page with PHP

am 28.01.2010 22:23:05 von Ashley Sheridan

--=-d7/+j8TdKqbaeHGW0UQt
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Thu, 2010-01-28 at 16:23 -0500, Paul M Foster wrote:

> On Fri, Jan 29, 2010 at 08:17:34AM +1100, clancy_1@cybec.com.au wrote:
>
> > On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:
> >
> > >On Thu, Jan 28, 2010 at 12:31 AM, wrote:
> > >> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
> > >>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!
> > >
> > >whenever i write an opening tag, i immediately write the closing tag
> > >next, then cursor back to fill it in.
> >
> > Not so easy when you are using PHP to generate a complex layout!
>
> Use heredocs to do it. Then you can generate the layout in PHP and still
> do what dealtek@gmail.com said.
>
> Paul
>
> --
> Paul M. Foster
>


Not really always. I often use fairly complex code to handle output of
content into tables where the number of columns varies on the content.
Cases like this are not something you can tackle with heredoc or nowdoc,
and don't allow you to just create the opening and closing tags and
build the PHP around them. Sometimes you just have to use your smarts a
bit :p

Of course, I do find that proper code indentation is of the absolute
importance, and running the output through a validator helps!

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-d7/+j8TdKqbaeHGW0UQt--

Re: Creating an Entire .html page with PHP

am 28.01.2010 22:39:31 von Michael Peters

clancy_1@cybec.com.au wrote:
> On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:
>
>> On Thu, Jan 28, 2010 at 12:31 AM, wrote:
>>> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
>>> 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!
>> whenever i write an opening tag, i immediately write the closing tag
>> next, then cursor back to fill it in.
>
> Not so easy when you are using PHP to generate a complex layout!
>
>

Use DOMDocument.
Then you don't have to worry about closing the tags ;)

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

Re: Creating an Entire .html page with PHP

am 28.01.2010 23:31:27 von Rene Veerman

On Thu, Jan 28, 2010 at 10:17 PM, wrote:
> On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wro=
te:
>
>>On Thu, Jan 28, 2010 at 12:31 AM, =A0 wrote:
>>> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
>>>Opening tables, etc, wrongly generally messes the page up completely, bu=
t
>>> forgetting to close them again often has no affect no visible effect at=
all -- until you
>>> make some innocent change and everything goes haywire!
>>
>>whenever i write an opening tag, i immediately write the closing tag
>>next, then cursor back to fill it in.
>
> Not so easy when you are using PHP to generate a complex layout!
>
>

eh, why not?

"complex" layouts can and should be split up into functions, which can
adhere to the same principle..

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

Re: Creating an Entire .html page with PHP

am 29.01.2010 15:45:11 von kingzones

--000e0cd17fa6bede0d047e4eae18
Content-Type: text/plain; charset=UTF-8

you can use Apache mod rewrite to create html pages having all programing
saved in .php pages. I have never tried generating .html pages with this but
have successfully generated .htm pages..

Hope this works..

On Tue, Jan 26, 2010 at 6:30 AM, dealtek@gmail.com wrote:

> Hi Folks,
>
> I would like to create an entire .html page gathered from database content
> mixed with html etc. and be able to save the page...
>
>
> like:
>
> --- save all this pre made content as .html page....
>
>
>
> ... stuff
>
>
> ... stuff
> ... stuff with database query results...
> ... stuff
>
>
>
> Q: Is there a function that might help with saving the whole content as
> .html page?
>
>
>
> Thanks,
> dealtek@gmail.com
> [db-10]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
http://www.kingzones.org/

--000e0cd17fa6bede0d047e4eae18--

Re: Creating an Entire .html page with PHP

am 29.01.2010 15:48:47 von Ashley Sheridan

--=-wYl4CxHArs7DTY9rOglx
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:

> you can use Apache mod rewrite to create html pages having all programing
> saved in .php pages. I have never tried generating .html pages with this but
> have successfully generated .htm pages..
>
> Hope this works..
>
> On Tue, Jan 26, 2010 at 6:30 AM, dealtek@gmail.com wrote:
>
> > Hi Folks,
> >
> > I would like to create an entire .html page gathered from database content
> > mixed with html etc. and be able to save the page...
> >
> >
> > like:
> >
> > --- save all this pre made content as .html page....
> >
> >
> >
> > ... stuff
> >
> >
> > ... stuff
> > ... stuff with database query results...
> > ... stuff
> >
> >
> >
> > Q: Is there a function that might help with saving the whole content as
> > .html page?
> >
> >
> >
> > Thanks,
> > dealtek@gmail.com
> > [db-10]
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>


You still have to create .php pages, mod_rewrite just masks what the
user is requesting through their browser. You can set Apache to
parse .html pages as PHP, but I wouldn't recommend it, as any html pages
that don't contain PHP code still have to be parsed as if they did,
which is slower.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-wYl4CxHArs7DTY9rOglx--

Re: Creating an Entire .html page with PHP

am 29.01.2010 18:53:44 von Robert Cummings

Ashley Sheridan wrote:
> On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:
>
>> you can use Apache mod rewrite to create html pages having all programing
>> saved in .php pages. I have never tried generating .html pages with this but
>> have successfully generated .htm pages..
>>
>> Hope this works..
>>
>> On Tue, Jan 26, 2010 at 6:30 AM, dealtek@gmail.com wrote:
>>
>>> Hi Folks,
>>>
>>> I would like to create an entire .html page gathered from database content
>>> mixed with html etc. and be able to save the page...
>>>
>>>
>>> like:
>>>
>>> --- save all this pre made content as .html page....
>>>
>>>
>>>
>>> ... stuff
>>>
>>>
>>> ... stuff
>>> ... stuff with database query results...
>>> ... stuff
>>>
>>>
>>>
>>> Q: Is there a function that might help with saving the whole content as
>>> .html page?
>>>
>>>
>>>
>>> Thanks,
>>> dealtek@gmail.com
>>> [db-10]
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>
>
> You still have to create .php pages, mod_rewrite just masks what the
> user is requesting through their browser. You can set Apache to
> parse .html pages as PHP, but I wouldn't recommend it, as any html pages
> that don't contain PHP code still have to be parsed as if they did,
> which is slower.

You can also do the following:

AddType application/x-httpd-php .php .html .htm

And then rewrite is unnecessary.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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

Re: Creating an Entire .html page with PHP

am 30.01.2010 02:33:46 von Ashley Sheridan

--=-YOplcWNUFiLAQ6jOekub
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sat, 2010-01-30 at 12:34 +1100, clancy_1@cybec.com.au wrote:

> On Thu, 28 Jan 2010 13:39:31 -0800, mpeters@mac.com ("Michael A. Peters") wrote:
>
> >clancy_1@cybec.com.au wrote:
> >> On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:
> >>
> >>> On Thu, Jan 28, 2010 at 12:31 AM, wrote:
> >>>> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
> >>>> 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!
> >>> whenever i write an opening tag, i immediately write the closing tag
> >>> next, then cursor back to fill it in.
> >>
> >> Not so easy when you are using PHP to generate a complex layout!
> >>
> >>
> >
> >Use DOMDocument.
> >Then you don't have to worry about closing the tags ;)
>
> Ohhh? The index page of the manual has 110 lines of totally meaningless entries, and the
> introduction doesn't open. I haven't the faintest idea what it's all about, but I very
> much doubt if it would mean anything to the original writer.
>
>


I've never used DomDoument to create an HTML page, and I probably never
will. I also don't have much of a problem with creating decent html code
that validates either.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-YOplcWNUFiLAQ6jOekub--

Re: Creating an Entire .html page with PHP

am 30.01.2010 02:34:57 von Clancy

On Thu, 28 Jan 2010 13:39:31 -0800, mpeters@mac.com ("Michael A. Peters") wrote:

>clancy_1@cybec.com.au wrote:
>> On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:
>>
>>> On Thu, Jan 28, 2010 at 12:31 AM, wrote:
>>>> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
>>>> 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!
>>> whenever i write an opening tag, i immediately write the closing tag
>>> next, then cursor back to fill it in.
>>
>> Not so easy when you are using PHP to generate a complex layout!
>>
>>
>
>Use DOMDocument.
>Then you don't have to worry about closing the tags ;)

Ohhh? The index page of the manual has 110 lines of totally meaningless entries, and the
introduction doesn't open. I haven't the faintest idea what it's all about, but I very
much doubt if it would mean anything to the original writer.


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

Re: Creating an Entire .html page with PHP

am 30.01.2010 02:47:25 von Clancy

On Thu, 28 Jan 2010 16:23:05 -0500, paulf@quillandmouse.com (Paul M Foster) wrote:

>On Fri, Jan 29, 2010 at 08:17:34AM +1100, clancy_1@cybec.com.au wrote:
>
>> On Thu, 28 Jan 2010 21:10:42 +0100, rene7705@gmail.com (Rene Veerman) wrote:
>>
>> >On Thu, Jan 28, 2010 at 12:31 AM, wrote:
>> >> On Wed, 27 Jan 2010 10:21:00 -0800, dealtek@gmail.com (dealtek) wrote:
>> >>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!
>> >
>> >whenever i write an opening tag, i immediately write the closing tag
>> >next, then cursor back to fill it in.
>>
>> Not so easy when you are using PHP to generate a complex layout!
>
>Use heredocs to do it. Then you can generate the layout in PHP and still
>do what dealtek@gmail.com said.

I don't think heredocs is relevant. The original writer wanted to save the HTML output of
a working page to a file, whereas (I think!) heredocs are involved with getting messy
stuff into PHP.

I still think that simply capturing the page from the browser is the simplest solution for
the original question, but if you want a more elegant one see:

http://codeutopia.net/blog/2007/10/03/how-to-easily-redirect -php-output-to-a-file/

The writer appears to know what he's talking about, and I am pleased to have found this,
as I have often wanted to to redirect PHP output to a file.


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

Re: Creating an Entire .html page with PHP

am 30.01.2010 19:16:39 von Ashley Sheridan

--=-xcbsU9qwbjRw4ZhYZ793
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, 2010-01-30 at 19:20 +0100, Nisse Engström wrote:

> On Fri, 29 Jan 2010 14:48:47 +0000, Ashley Sheridan wrote:
>=20
> > On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:
> >=20
> >> you can use Apache mod rewrite to create html pages having all program=
ing
> >> saved in .php pages. I have never tried generating .html pages with th=
is but
> >> have successfully generated .htm pages..
> >=20
> > You still have to create .php pages, mod_rewrite just masks what the
> > user is requesting through their browser. You can set Apache to
> > parse .html pages as PHP, but I wouldn't recommend it, as any html page=
s
> > that don't contain PHP code still have to be parsed as if they did,
> > which is slower.
>=20
> .htaccess:
> DirectoryIndex index.php
>=20
>=20
> /Nisse
>=20


That would only set the index for a given directory, it doesn't force
Apache to run that script when something else is called.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-xcbsU9qwbjRw4ZhYZ793--

Re: Creating an Entire .html page with PHP

am 30.01.2010 19:20:36 von news.NOSPAM.0ixbtqKe

On Fri, 29 Jan 2010 14:48:47 +0000, Ashley Sheridan wrote:

> On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:
>
>> you can use Apache mod rewrite to create html pages having all programing
>> saved in .php pages. I have never tried generating .html pages with this but
>> have successfully generated .htm pages..
>
> You still have to create .php pages, mod_rewrite just masks what the
> user is requesting through their browser. You can set Apache to
> parse .html pages as PHP, but I wouldn't recommend it, as any html pages
> that don't contain PHP code still have to be parsed as if they did,
> which is slower.

..htaccess:
DirectoryIndex index.php


/Nisse

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

Re: Creating an Entire .html page with PHP

am 30.01.2010 19:37:34 von Ashley Sheridan

--=-e9SSUWZwi3n0F9iPIgr4
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, 2010-01-30 at 13:40 -0500, Robert Cummings wrote:

> Ashley Sheridan wrote:
> > On Sat, 2010-01-30 at 19:20 +0100, Nisse Engström wrote:
> >=20
> >> On Fri, 29 Jan 2010 14:48:47 +0000, Ashley Sheridan wrote:
> >>
> >>> On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:
> >>>
> >>>> you can use Apache mod rewrite to create html pages having all progr=
aming
> >>>> saved in .php pages. I have never tried generating .html pages with =
this but
> >>>> have successfully generated .htm pages..
> >>> You still have to create .php pages, mod_rewrite just masks what the
> >>> user is requesting through their browser. You can set Apache to
> >>> parse .html pages as PHP, but I wouldn't recommend it, as any html pa=
ges
> >>> that don't contain PHP code still have to be parsed as if they did,
> >>> which is slower.
> >> .htaccess:
> >> DirectoryIndex index.php
> >>
> >>
> >> /Nisse
> >>
> >=20
> > That would only set the index for a given directory, it doesn't force
> > Apache to run that script when something else is called.
>=20
> I answered this issue yesterday with the following:
>=20
> AddType application/x-httpd-php .php .html .htm
>=20
> I think tedd also adds .css :)
>=20
> Cheers,
> Rob.
> --=20
> http://www.interjinn.com
> Application and Templating Framework for PHP
>=20


I thought that doing that introduced slowdowns where Apache was parsing
html files that didn't contain PHP code though?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-e9SSUWZwi3n0F9iPIgr4--

Re: Creating an Entire .html page with PHP

am 30.01.2010 19:40:03 von Robert Cummings

Ashley Sheridan wrote:
> On Sat, 2010-01-30 at 19:20 +0100, Nisse Engström wrote:
>
>> On Fri, 29 Jan 2010 14:48:47 +0000, Ashley Sheridan wrote:
>>
>>> On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:
>>>
>>>> you can use Apache mod rewrite to create html pages having all programing
>>>> saved in .php pages. I have never tried generating .html pages with this but
>>>> have successfully generated .htm pages..
>>> You still have to create .php pages, mod_rewrite just masks what the
>>> user is requesting through their browser. You can set Apache to
>>> parse .html pages as PHP, but I wouldn't recommend it, as any html pages
>>> that don't contain PHP code still have to be parsed as if they did,
>>> which is slower.
>> .htaccess:
>> DirectoryIndex index.php
>>
>>
>> /Nisse
>>
>
> That would only set the index for a given directory, it doesn't force
> Apache to run that script when something else is called.

I answered this issue yesterday with the following:

AddType application/x-httpd-php .php .html .htm

I think tedd also adds .css :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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

Re: Creating an Entire .html page with PHP

am 30.01.2010 19:45:33 von Robert Cummings

Ashley Sheridan wrote:
> On Sat, 2010-01-30 at 13:40 -0500, Robert Cummings wrote:
>> Ashley Sheridan wrote:
>> > On Sat, 2010-01-30 at 19:20 +0100, Nisse Engström wrote:
>> >
>> >> On Fri, 29 Jan 2010 14:48:47 +0000, Ashley Sheridan wrote:
>> >>
>> >>> On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote:
>> >>>
>> >>>> you can use Apache mod rewrite to create html pages having all programing
>> >>>> saved in .php pages. I have never tried generating .html pages with this but
>> >>>> have successfully generated .htm pages..
>> >>> You still have to create .php pages, mod_rewrite just masks what the
>> >>> user is requesting through their browser. You can set Apache to
>> >>> parse .html pages as PHP, but I wouldn't recommend it, as any html pages
>> >>> that don't contain PHP code still have to be parsed as if they did,
>> >>> which is slower.
>> >> .htaccess:
>> >> DirectoryIndex index.php
>> >>
>> >>
>> >> /Nisse
>> >>
>> >
>> > That would only set the index for a given directory, it doesn't force
>> > Apache to run that script when something else is called.
>>
>> I answered this issue yesterday with the following:
>>
>> AddType application/x-httpd-php .php .html .htm
>>
>> I think tedd also adds .css :)
>>
>> Cheers,
>> Rob.
>> --
>> http://www.interjinn.com
>> Application and Templating Framework for PHP
>>
>
> I thought that doing that introduced slowdowns where Apache was parsing
> html files that didn't contain PHP code though?

It does... if your files don't have PHP. I imagine (but haven't checked)
that you can set this on a virtual host basis. So then it becomes a
question of utility versus wasted cycles. How many PHP sites actually
bother to create .html files when there's no PHP code?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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