Php 哪些HTTP响应代码是错误?
我希望根据响应代码决定应显示的模板(视图):Php 哪些HTTP响应代码是错误?,php,http,error-handling,http-status-codes,Php,Http,Error Handling,Http Status Codes,我希望根据响应代码决定应显示的模板(视图): $codes = array( 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information',
$codes = array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Time-out',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Large',
415 => 'Unsupported Media Type',
416 => 'Requested range not satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Time-out',
);
我知道2xx表示一切正常,因此对于2xx,我可以显示与请求相关联的模板文件
这是否意味着所有其他的都是错误,我应该显示一个标准的“错误”模板?是客户端错误
是服务器错误
这些都不是错误
请参阅(状态代码和原因短语)
你应该考虑处理<代码> 418我是一个茶壶< /代码>以及超文本咖啡壶控制协议。< /P> < P>代码4xx和5xx,如列表中所给出的。< /P>
其他代码不是错误任何以4(4xx)开头的代码都是客户端错误(由于客户端发出了服务器无法满足或理解的请求而导致的错误) 任何以5(5xx)开头的代码都是服务器错误(由于服务器配置中的某些问题而导致的错误)
1xx代码是信息性的,2xx表示成功的结果,3xx表示重定向(304 not Mofied除外,它表示浏览器已具有请求资源的最新版本) 这些状态不是请求,而是响应!根据发送到服务器的实际请求(基本上是URI+GET+POST),您有责任确定回复的状态。