|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-02-22 05:10 UTC] php_bugs at ecora dot de
Description:
------------
Hi,
<Documentation>
header("HTTP/1.0 404 Not Found");
[...]
Note: In PHP 3, this only works when PHP is compiled as an Apache module. You can achieve the same effect using the Status header.
header("Status: 404 Not Found");
</Documentation>
IMHO this is not correct. Because the HTTP-status-header (also Content-Type- and Location-Header) is always a server parsed header, when PHP (PHP3, PHP4, PHP5 or also Perl or Python, ...) runs via CGI.
The official CGI Specification (see http://www.w3.org/CGI/):
http://hoohoo.ncsa.uiuc.edu/cgi/out.html
That means not only in PHP3 also in PHP4 or PHP5: When PHP runs via CGI, then you have to write:
header("Status: 404 Not Found"); instead of header("HTTP/1.0 404 Not Found");
Reproduce code:
---------------
When i try to send a header("HTTP/1.0 404 Not Found"); on my installation (Apache 1.3.29 + PHP 4.2.3 CGI on Linux) then i receive a 500 internal server error
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 01:00:02 2025 UTC |
I couldn't reproduce this in PHP 5. header("HTTP/1.0 404 Not Found"); print "Status: 404" and header("Status: 404 Not Found"); prints "Status: 404 Not Found" Can anybody check this in PHP 4?This is a bug, but not a documentation one. Both PHP4 and PHP5 just send "HTTP/1.1 404\r\n"... when doing header('HTTP/1.0 404 Not found'); which isn't conforming to RFC 2616 (There has to be at least one space after 404). That may cause Webservers to error out. This is definitively a bug. I don't think the "reason-phrase" should be discarded at all.Nope, that's simply not true. It doesn't matter what you pass to header(). What matters is the output created by PHP, and if you use header("HTTP/1.0 404 Foo Bar"); PHP parses that and turns it into a Status: line if you use CGI.