PHP 4.0 Bug #3610: Header( ) Output requires echo after to flush output
| From: | tswan at ics dot olemiss dot edu | Date: | Thu, 24 Feb 2000 21:33:27 +0000 |
| Subject: | PHP 4.0 Bug #3610: Header( ) Output requires echo after to flush output | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-15959@lists.php.net to get a copy of this message | ||
From: tswan@ics.olemiss.edu
Operating system: RedHat Linux 6.0 (2.2.14)
PHP version: 4.0 Beta 4 Patch Level 1
PHP Bug Type: Scripting Engine problem
Bug description: Header( ) Output requires echo after to flush output
__*** PROBLEM ***___
I included the script and the important part of the output'd HTML. The problem was that the
headers weren't output at the right time. I think it might be something with the scoping of
the output lines in the if statement apparently it doesn't think output is happening until the
return of this function. If I'm way out on limb, just cut it and let me fall. BTW, the
compile options are included after the output section.
This function was called from a different script file referencing it as
require('common.php3');
This worked correctly under PHP 3.0.12-3.0.14.
Also, this is one of my first scripts using PHP so I don't have a lot of style or effeciency in
this one, and since it works, I haven't bothered to change it until now.
Please note this code was inside a function that I called for a general purpose header...
--***** SCRIPT *****__
header("Content-Type: text/html"); // Type of Content
header("Expires: Mon, 20 Jul 1978 05:00:00 GMT"); // Date in the past
header("Last-Modified:" . gmdate("D, d M Y H:i:s") . " GMT"); //
always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0
echo "\n";
// REQUIRED TO OUTPUT...
global $debug;
global $background_color;
if ($debug) {
echo ("<HTML>\n<HEAD>\n<TITLE>\n</TITLE>\n");
echo "<LINK REL=FONTDEF SRC=/pfrs/Zurich.pfr>\n";
echo "<LINK REL=FONTDEF SRC=/pfrs/Rage_Italic_LET_Plain.pfr>\n";
echo "<LINK REL=STYLESHEET TYPE=text/css HREF=/stylesheets/normal.css
TITLE=normal>\n";
echo ("</HEAD>\n");
if (empty($background_color)) {
echo "<BODY STYLE=\"background-image: none;\"
BGCOLOR=\"#DDDDDD\">\n";
} else {
echo "<BODY STYLE=\"background-image: none;\" BGCOLOR=\"" .
$background_color . "\">\n<P>\n";
}
} else {
virtual("includes/section_00.html");
virtual("includes/section_01.html");
switch ($section) {
case "ICS Administration" :
echo "<IMG SRC=\"../images/toolbar_image_01.gif\"
NAME=\"main_top_middle\" WIDTH=224 HEIGHT=110 BORDER=0 VSPACE=0 HSPACE=0 VALIGN=TOP
ALIGN=LEFT>";
break;
default :
echo "<IMG NAME=\"main_top_middle\" WIDTH=224 HEIGHT=11 BORDER=0 VSPACE=0
HSPACE=0 VALIGN=TOP ALIGN=LEFT>";
}
virtual("includes/section_02.html");
echo $section . "\n";
virtual("includes/section_03.html");
echo $sub_section . "\n";
virtual("includes/section_05.html");
}
--******************************************---
This produced the output...
--******************************************---
<HTML>
<HEAD>
<TITLE>The Institute for Continuing Studies</TITLE>
<META NAME="RATING" CONTENT="General">
<META NAME="AUTHOR" CONTENT="Thomas Swan, Amelia Rodgers, Britt
Fitts">
<META NAME="DESIGN" CONTENT="Thomas Swan">
<META NAME="COPYRIGHT" CONTENT="Copyright 1999, University of
Mississippi">
<META HTTP-EQUIV="REPLY-TO"
CONTENT="webteam@tangent.ics.olemiss.edu%20(Comments)">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen
true comment "RSACi North America Server" for "http://www.ics.olemiss.edu" on
"1999.09.07T16:42-0800" r (n 0 s 0 v 0 l 0))'>
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "http://www.classify.org/safesurf/" l r
(SS~~000 1))'>
</HEAD>
<LINK REL=FONTDEF SRC="/pfrs/Zurich.pfr">
<LINK REL=STYLESHEET TYPE="text/css" HREF="/stylesheets/normal.css"
TITLE="normal">
<!-- start Bitstream TDServer.ocx support -->
<SCRIPT LANGUAGE="JavaScript" SRC="http://www.ics.olemiss.edu/activex/tdserver.js">
</SCRIPT>
<!-- end Bitstream TDServer.ocx support -->
<!-- IE cannot used burned fonts due to a design flaw, therefore we need to add some usefulness
to it... :) -->
<SCRIPT LANGUAGE="Javascript">
var bannerColor="#000066";
var toolbar_offset = 0;
function setBannerColor (newColor) {
bannerColor=newColor;
}
</SCRIPT>
<BODY BACKGROUND="../images/pinstripe_blue.jpg" BGCOLOR="#FFFFFF"
TEXT="#000000" ALINK="#660000" VLINK="#005044"
LINK="#005044" MARGINWIDTH=0 MARGINHEIGHT=0>
<BASEFONT FACE="'Zurich BT', Helvetica, Arial, 'Sans Serif', SansSerif,
sans-serif, sanserif" SIZE=2 PIXEL-SIZE="14px">
<TABLE BORDER=0 WIDTH=100% HEIGHT=110 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD ROWSPAN=7 COLSPAN=1 WIDTH=37 HEIGHT=110 VALIGN=TOP ALIGN=LEFT BGCOLOR=WHITE
BACKGROUND="../images/ics_toolbar_background_c.jpg" STYLE="background-repeat:
no-repeat">
<IMG ALT="" SRC="../images/top_left_wedge.gif"
NAME="main_top_left" WIDTH=37 HEIGHT=110 BORDER=0 VSPACE=0 HSPACE=0 VALIGN=TOP
ALIGN=LEFT>
</TD>
<TD ROWSPAN=7 COLSPAN=1 WIDTH=224 HEIGHT=110 VALIGN=TOP ALIGN=LEFT BGCOLOR=WHITE
BACKGROUND="../images/ics_toolbar_background_g.jpg" STYLE="background-repeat:
no-repeat">
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2000 20:50:01 GMT
Server: Apache/1.3.6 (Unix) (Red Hat/Linux) PHP/4.0b4pl1
X-Powered-By: PHP/4.0b4pl1
Expires: Mon, 20 Jul 1978 05:00:00 GMT
Last-Modified: Thu, 24 Feb 2000 20:50:01 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/html
<IMG NAME="main_top_middle" WIDTH=224 HEIGHT=110 BORDER=0 VSPACE=0 HSPACE=0 VALIGN=TOP
ALIGN=LEFT> </TD>
<TD ROWSPAN=1 COLSPAN=1 WIDTH="95%" HEIGHT=11 VALIGN=TOP ALIGN=LEFT>
<IMG ALT="" SRC="../images/clear_5x5.gif" WIDTH=5 HEIGHT=11 BORDER=0
VSPACE=0 HSPACE=0 VALIGN=TOP ALIGN=LEFT>
__**** REST OMITTED FOR BREVITY ****____
__*** Compilied Options ***___
Configure command: ./configure '--prefix=/usr' '--localstatedir=/var'
'--with-config-file-path=/etc/httpd' '--enable-magic-quotes'
'--enable-trans-sid' '--enable-safe-mode'
'--enable-shared' '--enable-static' '--disable-track-vars'
'--enable-freetype-4bit-antialias-hack' '--with-x' '--with-apxs'
'--with-cpdflib=/usr' '--with-pdflib=/usr' '--with-jpeg-dir=/usr'
'--with-tiff-dir=/usr' '--with-gdbm' '--with-zlib-dir=/usr'
'--with-imap=/usr/src/imap/c-client' '--with-ftp' '--with-gd=/usr'
'--with-ttf=/usr' '--with-mysql=/usr' '--with-png-dir=/usr'
'--with-regex=php' '--enable-sysvsem' '--enable-sysvshm'
'--enable-versioning' '--enable-inline-optimization' '--with-gnu-dl'
php.ini path: /etc/httpd
ZEND_DEBUG=1
SAPI=Apache
ZTS is undefined
Compiled using gcc 1.1.3 (Whatever shipped with RH 6.0)
Apache version 1.3.6
EXTRA_OPTS = '-march=pentiumpro -fexpensive-optimizations'
__*** NOTES ***__
_ I'll be working on a smaller test case __ :)