|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-07-31 07:17 UTC] czirkos dot zoltan at gmail dot com
Description: ------------ The http_response_code() function fails for a nonstandard error code (eg. 210). 500 Internal Server Error is emitted instead. This only happens with the apache2handler SAPI; eg. Nginx+FPM works fine. Test script: --------------- http_response_code(210); echo "hello"; Expected result: ---------------- Proper error code sent via the server. Please not that documenting the list of error codes (in the documentation at http://php.net/manual/en/function.http-response-code.php) is not really a solution, as custom error codes can be defined. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 07:00:01 2025 UTC |
http_response_code() depends on the SAPI (Apache or FPM+nginx) supporting the code. nginx doesn't mind a custom 210 but Apache does and it (not PHP) substitutes a 500 instead [1]. If you want a custom status then use header(), which Apache handles differently than if you just give the code. header("HTTP/1.1 210 Whatever That Code Means"); [1] They support 200 OK through 208 Already Reported. Anything 2xx above that will be rejected. See their modules/http/http_protocol.c for more. https://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http/http_protocol.c?revision=1799890