|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25890 Strange behaviour of header() function
Submitted: 2003-10-16 12:13 UTC Modified: 2003-10-17 08:01 UTC
From: cysgwr_eryri at yahoo dot co dot uk Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 4.3.3 OS: Mandrake 9.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
21 - 11 = ?
Subscribe to this entry?

 [2003-10-16 12:13 UTC] cysgwr_eryri at yahoo dot co dot uk

I'm not sure whether this is a bug or a configuration error, but it has me stumped. I've searched the bugs and can't quite find anything exactly the same. Ironically, a number of people have complained about 'Location: ' not working, but it works perfectly here, and that's not what my problem is.

Operating system is Mandrake 9.1. Web Server is Apache 1.38 with php 4.3.3 (problem occurs whether either statically compiled-in or as dynamic .so using apxs), with mod_perl 1.28 as a dynamic .so under apxs (problem occurs whether this is loaded or not). Problem occurs whether using php.ini-dist or a customised version. All ingredients compiled from source.

I was trying to change some of the headers. The production code is massive and unwieldy, but managed to display the same symptoms with code reproduced below.

In short: On a normal request the server reponds as follows:

HTTP/1.1 200 OK
Date: Thu, 16 Oct 2003 15:44:22 GMT
Server: Apache/1.3.28 (Unix) mod_perl/1.28 PHP/4.3.3
X-Powered-By: PHP/4.3.3
Connection: close
Content-Type: text/html

However, trying to change *any* of the headers that are already present fails. This fails whether you specify the boolean 'append' value or not (if not, nothing is changed, if you specify 'appended', nothing is added). Adding other headers works perfectly fine, but trying to change those already present does not. 

Using the code provided the server returns this:

HTTP/1.1 200 OK
Date: Thu, 16 Oct 2003 16:07:54 GMT
Server: Apache/1.3.28 (Unix) mod_perl/1.28 PHP/4.3.3
X-Powered-By: PHP/4.3.3
Foo: Bar
Monkey: Nuts
Connection: close
Content-Type: text/html

The new headers are added perfectly correctly, but the old ones are not altered at all. Is is just that these two headers are unalterable, is this a bug, or could it be a configuration issue?

Reproduce code:
//change headers (older date, different server)
	header('Server: Monkey/1.0');
	header('Date: Mon, 18 Nov 2002 11:24:52 GMT');
//add other headers for testing...
	header("Foo: Bar");
	header("Monkey: Nuts");


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-16 20:57 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Certain headers such as date & server cannot be manipulated due to Apache's limitations on such changes, this has nothing to do with PHP.
 [2003-10-17 04:53 UTC] cysgwr_eryri at yahoo dot co dot uk
I can fully appreciate that, iliaa, and thank you for responding and fully explaining the issue.

The reason I want to change those headers is to get around the shortcomings of an archaic client.

I appreciate that, technically, it is not a bug in PHP itself. I've written compiled modules for Apache, and I fully understand that the API is complete and utter nightmare. However, in which case, surely this *is* a bug in the sense that it pertains to a *documentation omission* as opposed to an HTTP issue.

I couldn't find this information anywhere, and a short sentence in the documentation pertaining to issues relating to the *most popular http server on the planet*, and which headers can and cannot be changed, would have gone a long way. Thank you again for your time and effort.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Mar 31 04:03:39 2023 UTC