PHP: How to send HTTP response code?

后端 未结 9 1973
无人共我
无人共我 2020-11-22 06:05

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?

9条回答
  •  滥情空心
    2020-11-22 06:16

    since PHP 5.4 you can use http_response_code() for get and set header status code.

    here an example:

    
    

    here is the document of this function in php.net:

    http_response_code

提交回复
热议问题