note 93682 added to function.header
| From: | guy dot paddockATgmailDOTcom at osu1 dot php dot net | Date: | Tue, 22 Sep 2009 19:40:05 +0000 |
| Subject: | note 93682 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160949@lists.php.net to get a copy of this message | ||
The use of the $http_response_code parameter is a little unclear in the docs, especially because the
only example of how to send an HTTP status code header doesn't even use the parameter.
The point of the parameter is to have PHP automatically translate an HTTP status code to its
corresponding phrase (404 because "404 Not Found"), just as "fgif2 at yahoo dot
fr" mentioned. In my case, an application I'm developing puts appropriate HTTP status
codes in for the "code" parameter of any thrown exceptions, to allow pages to translate
the exceptions into HTTP errors when issues are encountered.
The example "fgif2 at yahoo dot fr" provides is counter-intuitive, because he passes
"NULL" for the $replace boolean parameter and "TRUE" for the $string string
parameter.
Here's a more straightforward example for sending a 500 response:
<?php
header('HTTP', true, 500);
?>
----
Server IP: 209.41.74.194
Probable Submitter: 129.21.225.231
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/93682
Del: integrated -- https://master.php.net/note/delete/93682/integrated
Del: useless -- https://master.php.net/note/delete/93682/useless
Del: bad code -- https://master.php.net/note/delete/93682/bad+code
Del: spam -- https://master.php.net/note/delete/93682/spam
Del: non-english -- https://master.php.net/note/delete/93682/non-english
Del: in docs -- https://master.php.net/note/delete/93682/in+docs
Del: other reasons-- https://master.php.net/note/delete/93682
Reject -- https://master.php.net/note/reject/93682
Search -- https://master.php.net/manage/user-notes.php