php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49592 Incorrect description of header() behavior
Submitted: 2009-09-18 16:19 UTC Modified: 2009-09-21 09:09 UTC
From: travis at gymgenius dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.11 OS:
Private report: No CVE-ID: None
 [2009-09-18 16:19 UTC] travis at gymgenius dot com
Description:
------------
The manual for header() states that:

"The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless some 3xx status code has already been set. "

PHP not only preserves 3xx status codes, but also appears to preserve the 201 status code (which is desirable because the 201 code can also accompany the Location header field).

Reproduce code:
---------------
header('HTTP/1.1 201 Created', true, 201);
header('Location: http://www.php.net');

Expected result:
----------------
HTTP/1.1 302 Found    (if you go by the manual)

Actual result:
--------------
HTTP/1.1 201 Created

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-21 09:08 UTC] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=288513
Log: Document that a previously-set 201 status code will also affect the
magic handling of 'Location:'.
Addresses bug #49592.
 [2009-09-21 09:09 UTC] torben@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

PHP also looks for the 201 code when making this determination. This has now been mentioned in the docs.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 07:00:01 2026 UTC