php - getStatusCode() - Return http status codes


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.