在php中,我希望在进一步处理之前提供自定义的错误消息。
这是我有的

if($overloaded==true){
    header('HTTP/1.0 503 Service Temporarily Unavailable');
    header('Status: 503 Service Temporarily Unavailable');
    header('Retry-After: 300');//300 seconds
    die();
}

发件人:How do I make php page return a 503 error (or anything non-200)
w3.org上约有503项服务不可用:
  Note: The existence of the 503 status code does not imply that a
  server must use it when becoming overloaded. Some servers may wish
  to simply refuse the connection.

发件人:http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4
当服务器过载时,我应该如何服务http请求?

最佳答案

如果你想准确点,据我所知,你只有两个选择,那就是503或500。
500意味着您因意外情况/原因无法满足请求。
503表示由于服务器的临时过载或维护,您无法完成请求。
据我所知,错误500是一个非常普遍的错误,503是最准确的,我强烈建议您使用超过500。准确总是最好的。

关于php - 服务器过载时要发送什么头代码?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27066755/

10-10 19:14