RE: [PHP] Include vs. Header
| From: | David Robley | Date: | Mon, 09 Oct 2000 01:02:26 +0000 |
| Subject: | RE: [PHP] Include vs. Header | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19130@lists.php.net to get a copy of this message | ||
On Mon, 09 Oct 2000, Richard Kirk wrote:
> I have a sort of related question about include/require.
> Rather than hard code the standard HTML header I want to outptut it using a
> function in an include file.
> e.g.
>
> <?php
> function outputHTMLHeader ( $pTitle="Title Of HTML Page" )
> {
> print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
> <html>
> <head>
> <title>$pTitle</title>
> </head>
> <body>" );
> }
> ?>
>
> This is fine and works on the GET of my page. After my page is posted I do a
> header() redirect but I get an error saying
>
> "Cannot add header information - headers already sent ..."
>
> This implies that because the function is included previously in the script,
> that it is also executed, but no call to this function is made before the
> header() redirect.
> If I move the include after the header() then it works fine. I don't however
> understand why it should behave differently, as including a file with
> functions in it surely doesn't execute those functions without an explicit
> call, does it?
>
>
> PHP Version 4.0.2
> Win98(2)
Try removing the blank line from your included file.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA