php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3610 Header( ) Output requires echo after to flush output
Submitted: 2000-02-24 16:33 UTC Modified: 2000-07-29 16:29 UTC
From: tswan at ics dot olemiss dot edu Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Beta 4 Patch Level 1 OS: RedHat Linux 6.0 (2.2.14)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tswan at ics dot olemiss dot edu
New email:
PHP Version: OS:

 

 [2000-02-24 16:33 UTC] tswan at ics dot olemiss dot edu
__*** 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 __ :)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-02-24 16:38 UTC] tswan at ics dot olemiss dot edu
I forgot to remove the echo "\n"; after the headers.   It's what was 
required to get the headers output before the HTML text.  So, the 
output wouldn't have happened without that line being removed...

 [2000-03-01 16:46 UTC] joey at cvs dot php dot net
I am confused by your most recent comment...shouldn't this bug be closed?
 [2000-03-05 20:43 UTC] tswan at ics dot olemiss dot edu
The echo "\n"; immediately after the header() section was my workaround.   
Removing it would guaranty the output listed.  Sorry for the confusion...

 [2000-06-11 19:59 UTC] zeev at cvs dot php dot net
Does this bug still occur in PHP 4.0.0?  If it does, please try to reduce your reproducing script to a very short test case (ideally, under 10 lines) that demonstrate the problem.
 [2000-07-29 16:29 UTC] stas@php.net
old release, no feedback - closing
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 05:01:29 2024 UTC