PHP最全的Header给浏览器返回状态码函数

https://blog.csdn.net/hotlinhao/article/details/78234335

[php] view plain copy
 
  1. function httpStatus($num){//网页返回码  
  2.         static $http = array (  
  3.             100 => "HTTP/1.1 100 Continue",  
  4.             101 => "HTTP/1.1 101 Switching Protocols",  
  5.             200 => "HTTP/1.1 200 OK",  
  6.             201 => "HTTP/1.1 201 Created",  
  7.             202 => "HTTP/1.1 202 Accepted",  
  8.             203 => "HTTP/1.1 203 Non-Authoritative Information",  
  9.             204 => "HTTP/1.1 204 No Content",  
  10.             205 => "HTTP/1.1 205 Reset Content",  
  11.             206 => "HTTP/1.1 206 Partial Content",  
  12.             300 => "HTTP/1.1 300 Multiple Choices",  
  13.             301 => "HTTP/1.1 301 Moved Permanently",  
  14.             302 => "HTTP/1.1 302 Found",  
  15.             303 => "HTTP/1.1 303 See Other",  
  16.             304 => "HTTP/1.1 304 Not Modified",  
  17.             305 => "HTTP/1.1 305 Use Proxy",  
  18.             307 => "HTTP/1.1 307 Temporary Redirect",  
  19.             400 => "HTTP/1.1 400 Bad Request",  
  20.             401 => "HTTP/1.1 401 Unauthorized",  
  21.             402 => "HTTP/1.1 402 Payment Required",  
  22.             403 => "HTTP/1.1 403 Forbidden",  
  23.             404 => "HTTP/1.1 404 Not Found",  
  24.             405 => "HTTP/1.1 405 Method Not Allowed",  
  25.             406 => "HTTP/1.1 406 Not Acceptable",  
  26.             407 => "HTTP/1.1 407 Proxy Authentication Required",  
  27.             408 => "HTTP/1.1 408 Request Time-out",  
  28.             409 => "HTTP/1.1 409 Conflict",  
  29.             410 => "HTTP/1.1 410 Gone",  
  30.             411 => "HTTP/1.1 411 Length Required",  
  31.             412 => "HTTP/1.1 412 Precondition Failed",  
  32.             413 => "HTTP/1.1 413 Request Entity Too Large",  
  33.             414 => "HTTP/1.1 414 Request-URI Too Large",  
  34.             415 => "HTTP/1.1 415 Unsupported Media Type",  
  35.             416 => "HTTP/1.1 416 Requested range not satisfiable",  
  36.             417 => "HTTP/1.1 417 Expectation Failed",  
  37.             500 => "HTTP/1.1 500 Internal Server Error",  
  38.             501 => "HTTP/1.1 501 Not Implemented",  
  39.             502 => "HTTP/1.1 502 Bad Gateway",  
  40.             503 => "HTTP/1.1 503 Service Unavailable",  
  41.             504 => "HTTP/1.1 504 Gateway Time-out"  
  42.         );  
  43.         header($http[$num]);  
  44.         exit();  
  45.     }  


httpStatus(404); 返回404页面。

posted @ 2018-06-25 09:32  yangchunlong  阅读(270)  评论(0)    收藏  举报