PHP: How to send HTTP response code?
问题 I have a PHP script that needs to make responses with HTTP response codes (status-codes), like HTTP 200 OK, or some 4XX or 5XX code. How can I do this in PHP? 回答1: I just found this question and thought it needs a more comprehensive answer: As of PHP 5.4 there are three methods to accomplish this: Assembling the response code on your own (PHP >= 4.0) The header() function has a special use-case that detects a HTTP response line and lets you replace that with a custom one header("HTTP/1.1 200