|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16842 header() function doesn`t work
Submitted: 2002-04-26 01:16 UTC Modified: 2002-07-03 10:27 UTC
Avg. Score:5.0 ± 0.0
Reproduced:17 of 17 (100.0%)
Same Version:10 (58.8%)
Same OS:7 (41.2%)
From: sanya at mail dot ru Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.2.0 OS: Windows XP
Private report: No CVE-ID: None
 [2002-04-26 01:16 UTC] sanya at mail dot ru
It seem that header() function doesn`t work. I`ve tested this in simle script with few lines of code (server-side redirection).


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-26 01:20 UTC] sanya at mail dot ru
It seem that header() function doesn`t work. Test was quite simle script with few lines of code (server-side redirection).
 [2002-04-26 02:03 UTC]
You are supposed to search bug DB, first....
There are sevral duplicated reports for this.
 [2002-04-26 02:25 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

 [2002-04-27 14:46 UTC] wodzu at tonet dot pl
    header("Location: http://localhost/");

WinXP/Apache1.3.22/Apache module/Standard setup, standard modules

On MSIE 6.0 and Netscape 6 nothings happen. Script start and normal end without any error (error_reporting  =  E_ALL). But I'm still on testing page. It seems just don't work and without any errors. I check configuration hundred times but with nothing :(
 [2002-05-01 00:45 UTC] irik at irik dot org
I have experienced this same bug on my systems.  I upgraded from PHP 4.1.2 on W2k Professional running Apache 1.3.20 to PHP 4.2.0.  header() function seems to stop working.

<? header("Location:"); ?>

In any browser, no workie, workie, just blank page.

Downgrade to PHP 4.2.1 and the problem disappears.

A search of bug database on version 4.2.0 on all issues and all status' returns 244 results as of May 1, 2002 and this is the only mention of header() not working.
 [2002-05-01 06:16 UTC]
Reopened to confirm. 
 [2002-05-02 06:23 UTC] imshort at beer dot com
I've come over this too. On a Win95 / Omnithttpd - System. PHP 4.2.0 does not even return ANY headers. Thus, the httpd does not retrun anything to the browser.
This does work, however:
echo "Content-Type: text/plain\r\n\r\n";
echo "Some text";
 [2002-05-07 10:01 UTC] ray at codemain dot com
I have experienced this problem also with a very simple script:


error_log("redirecting to forums");

		// temp fix for broken PHP 4.2
		echo '<HTML><head>';
		echo '<META HTTP-EQUIV="Refresh" Content="0; URL=">';
		echo '</head><body></body></HTML>';

//		exit();
//		die();
 [2002-05-07 10:07 UTC] ray at codemain dot com
Oops.  Pardon the above accidental comment submission.

I have experienced this problem which causes the PHP to not complete the request.  It appears that the culprit is the exit() construct.  It also occurs with the die() function.  If you remove the exit(); call, the script does not error.

  echo 'ok..';

f you call the above script as script.php?test=1 with a valid URL for redirect, you will see this error manifest itself.

(Confirmed under FreeBSD 4.2)
 [2002-05-08 00:32 UTC] carstenseiler at hotmail dot com
PHP 4.2 with Apache 2.035 on Win2k Professional SP2
After upgrading to V4.2 I immediately had problems with the header() function.  Even a simple script:
header("Location: index.php");
does not work.  Blank page.
 [2002-05-25 11:33 UTC] ashpool7 at yahoo dot com
Have the same problem with 4.2.1.  Similar to carstenseiler.

Windows NT SP6a + Hotfixes on Apache 1.3.23.  Running as module.

Downgrading to 4.1.1 fixes it.
 [2002-06-06 14:30 UTC] juts at atlantic dot net
This bug is two weeks old.  Does anyone have any updates?

 [2002-06-07 14:10 UTC] m at burkmat dot nu
When I upgraded from 4.1.1 to 4.2.1 I got this problem too. I've gone through all of php.ini, comparing the values of 4.1.1 with those of 4.2.1. After some modifications (and apache/php restart), header() still does not work. Even though the values in php.ini are the same.

The weird thing is that Apache says it's running PHP/4.2.1 (as currently installed) but phpinfo() and phpversion() both say it's still 4.1.1. Even weirder is that "php -v" and "php -i" both says 4.2.1.
 [2002-06-07 14:38 UTC] m at burkmat dot nu
Apparently phpinfo() and phpversion() reads from php4ts.dll, which still was version 4.1.1 on my dev-machine. I simply replaced php4ts.dll (in \WINNT\system32) with the one that came in the php-4.2.1-Win32 distribution and header() now works flawless :)
 [2002-06-08 04:08 UTC]
User error > bogus
 [2002-06-08 04:13 UTC] cg at gordimer dot net
not the bug report is bogus - only the last user's comment.

Please reopen.
 [2002-06-08 04:47 UTC]
 [2002-06-09 10:40 UTC] sabedard at jig dot to
I am experiencing the same problem with 4.2.1 on Win2000.  The following code works fine with 4.1.2 but does not redirect in 4.2.1.  


if (isset($HTTP_POST_VARS["submit_login"])) {

	$tbp = new Users();
	$tbp->retrieveDb( "where user_id = '" .$HTTP_POST_VARS["fuser_id"]. "' and password='" .$HTTP_POST_VARS["fpassword"]. "'" );
	$uid = $tbp->getField("user_id");
	if (!$uid) { 
		$login_success = false;
	} else {
		$path = str_replace ("reg_login","reg_type",$PHP_SELF);
		$tbp->log("Directing to Location: http://" .$SERVER_NAME. $path);
		header ("Location: http://" .$SERVER_NAME. $path); 


Looking at my log the Location path is correct.  I have even tried surrounding this code by ob_start() and ob_end_flush() with no luck.   There is a reference in the header documnentation page indecating that referencing all variable with a @ will fix this problem.  But that just seems wrong.  Any workaround would be greatly appreciated.
 [2002-06-09 11:42 UTC] sabedard at jig dot to
I think I have the answer to this one.   If you are using the php4ts.dll from 4.2.1 with the old dlls from 4.1.2 (in the C:\php\dll and c:\php\extensions) this header problem will occur.  However, if you just replace these old dll's with the correct 4.2.1 versions all will be well.  Specifically I think mismatching c:\winnt\system32\php4ts.dll and c:\php\sapi\php4apache.dll is the real issue. Of course, the best way to solve this it to uninstall 4.1.2, clean the directory and install 4.2.1 :) 

 [2002-06-12 09:28 UTC]
So does this solution work for those experiencing this problem?
 [2002-06-24 13:07 UTC] kubacki at uwth dot uni-hannover dot de
No, the solution doesn't work for me. I've tested it with 4.2.0, 4.2.1 and 4.3.0-dev and it doesn't work.
 [2002-06-25 04:05 UTC] kubacki at uwth dot uni-hannover dot de
I've noriced the bug only occurs if you're using PHP as module. Running it as CGI solves the problem in the mentioned versions.
Probably there's something about the module?
 [2002-07-03 04:18 UTC] kubacki at uwth dot uni-hannover dot de
Just noticed the bug doesn't occur for me with the module Dll of 4.2.2-dev. Fixed?
 [2002-07-03 10:27 UTC]
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at In case this was a documentation 
problem, the fix will show up soon at
In case this was a website problem, the change will show
up on the site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 21:01:27 2023 UTC