Bug #13933 Updated: error_log and HTTP redirect using header conflict

From: Date: Mon, 12 Nov 2001 22:01:24 +0000
Subject: Bug #13933 Updated: error_log and HTTP redirect using header conflict
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-70272@lists.php.net to get a copy of this message
ID: 13933
Updated by: zak
Reported By: bonseb@free.fr
Status: Open
Bug Type: Output Control
Operating System: Windows NT4 SP6
PHP Version: 4.0.6
New Comment:

Sounds like error_log() was generating an error message 
because the error_log directive was not set. Once the 
error message was generated, output would be sent to the 
browser, causing the headers to be sent and the header() 
call to fail.

Try unsetting the error_log directive in php.ini and run a 
script that only calls error_log().


Previous Comments:
------------------------------------------------------------------------

[2001-11-05 09:11:29] bonseb@free.fr

[Might be related to bug #11213]

Using :
NT4 SP6
Apache 1.3.20
PHP 4.0.6
Zend Optimizer 1.1 (bug reproduced without also)


I have a quite short PHP page needing to log something, and then switch to another PHP page.

I use the following PHP code :

error_log ($message, 0);
header("Location: new-location.php");

I then get the following error message :
Cannot add header information - headers already sent

If I remove the call to error_log, the problem disappears, but I won't get the event logged :(
Thus, error_log must be 'the one' producing the unexpected output.

If I swap the two calls, (header first, then error_log), I'll get to new-location.php, but
nothing will get logged :(

If I specify a filename in the call to error_log, and leave it in second position (see following
example), it works fine (except I don't automatically get the date and IP address of client
like I used to get in Apache's log).

error_log ($message, 3, 'd:/program files/apache group/apache/logs/error.log');


Here is my PHP configuration regarding logging functions :

error_reporting  =  E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = Off
log_errors = On


Let's add another strange behaviour. If I add the following line in php.ini :
error_log = d:/program files/apache group/apache/logs/error.log
and execute again the first example (error_log with 2 args and then header), it works fine :)

Any clues ?


------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=13933&edit=1



Thread (10 messages)

« previous php.dev (#70272) next »