php-getStatusCode()-返回http状态码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php-getStatusCode()-返回http状态码相关的知识,希望对你有一定的参考价值。

  1. function getStatusCodeMessage($status){
  2. // these could be stored in a .ini file and loaded
  3. // via parse_ini_file()... however, this will suffice
  4. // for an example
  5. $codes = Array(
  6. 100 => 'Continue',
  7. 101 => 'Switching Protocols',
  8. 200 => 'OK',
  9. 201 => 'Created',
  10. 202 => 'Accepted',
  11. 203 => 'Non-Authoritative Information',
  12. 204 => 'No Content',
  13. 205 => 'Reset Content',
  14. 206 => 'Partial Content',
  15. 300 => 'Multiple Choices',
  16. 301 => 'Moved Permanently',
  17. 302 => 'Found',
  18. 303 => 'See Other',
  19. 304 => 'Not Modified',
  20. 305 => 'Use Proxy',
  21. 306 => '(Unused)',
  22. 307 => 'Temporary Redirect',
  23. 400 => 'Bad Request',
  24. 401 => 'Unauthorized',
  25. 402 => 'Payment Required',
  26. 403 => 'Forbidden',
  27. 404 => 'Not Found',
  28. 405 => 'Method Not Allowed',
  29. 406 => 'Not Acceptable',
  30. 407 => 'Proxy Authentication Required',
  31. 408 => 'Request Timeout',
  32. 409 => 'Conflict',
  33. 410 => 'Gone',
  34. 411 => 'Length Required',
  35. 412 => 'Precondition Failed',
  36. 413 => 'Request Entity Too Large',
  37. 414 => 'Request-URI Too Long',
  38. 415 => 'Unsupported Media Type',
  39. 416 => 'Requested Range Not Satisfiable',
  40. 417 => 'Expectation Failed',
  41. 500 => 'Internal Server Error',
  42. 501 => 'Not Implemented',
  43. 502 => 'Bad Gateway',
  44. 503 => 'Service Unavailable',
  45. 504 => 'Gateway Timeout',
  46. 505 => 'HTTP Version Not Supported'
  47. );
  48.  
  49. return (isset($codes[$status])) ? $codes[$status] : '';
  50. }

以上是关于php-getStatusCode()-返回http状态码的主要内容,如果未能解决你的问题,请参考以下文章

HTTPClient 返回 HttpRequestException WinRT

Node.js 承诺请求返回

使用正则表达式 Oracle

各类http返回状态详解

HTTP PostAsync 不返回任何内容

服务器返回的status