RE: [PHP4BETA] Header() in PHP4
| From: | Samuel Liddicott | Date: | Thu, 26 Aug 1999 08:39:31 +0000 |
| Subject: | RE: [PHP4BETA] Header() in PHP4 | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3745@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Michael Stearne [mailto:MStearne@eisolutions.com]
> Sent: 26 August 1999 04:05 AM
> To: Peter Holt Hoffman
> Cc: Samuel Liddicott; php4beta@lists.php.net
> Subject: Re: [PHP4BETA] Header() in PHP4
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">
> <HTML>
> <HEAD>
>
> So, every generated page in Fusion has at least that code in it. I also
> believe there are other examples but I don't know any off hand. And also
> my original example was the comparison between the header() and
> CFLOCATION tags.
> I realize also I can auto_prepend files, but I am still looking at the
> header function.
This is how I would do it using a trick not many people realise.
DO have a prepend, and make it end with:
function DOC_HEAD() {
?>
and then just after your <HEAD> in your documents have like this:
<HEAD>
<?php } ?>
Then you have effectively define this function:
function DOC_HEAD() { ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">
<HTML>
<HEAD>
<?php }
This means every time your call DOC_HEAD it will output that html.
This means you don't have to have lots of complicated logic in your prepend
to work out if it would need the location header.
You can have all the logic at the point convenient to YOU and when you have
finished that logic, just call the DOC_HEAD(); function and then carry on!
Nifty trick, eh?
But otherwise, on php4 you will have no troubles anyway with the fact that
it is too late, because if you have output buffering on, with php4 you can
output headers at any time.
Sam