如下代码即可:

http_response_code(500);

或者:

header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);

代码摘录自:https://stackoverflow.com/questions/4162223/how-to-send-500-internal-server-error-error-from-a-php-script

Related Posts: PHP header如何发送500报错码 :

avatar