tags:

views:

51

answers:

3

I have an error.php file attached to ErrorHandler that will take the error HTTP status in as a GET variable. Is there an array I can find that has a mapping of status codes to error names and descriptions, or do I have to write one myself?

A: 

If you webserver is apache i think you can configure errorhandler like ../error.php?errno=404&errstr=Not Found

Svisstack
+3  A: 

You have to write this one yourself. It's easy - use http://bignosebird.com/apache/a5.shtml for reference

donis
...or [RFC 2616](http://tools.ietf.org/html/rfc2616), which would be more apt as reference...
Boldewyn
+1  A: 

Associative array version

$http_codes = array(
    100 => 'Continue',
    101 => 'Switching Protocols',
    102 => 'Processing',
    200 => 'OK',
    201 => 'Created',
    202 => 'Accepted',
    203 => 'Non-Authoritative Information',
    204 => 'No Content',
    205 => 'Reset Content',
    206 => 'Partial Content',
    207 => 'Multi-Status',
    300 => 'Multiple Choices',
    301 => 'Moved Permanently',
    302 => 'Found',
    303 => 'See Other',
    304 => 'Not Modified',
    305 => 'Use Proxy',
    306 => 'Switch 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 Timeout',
    409 => 'Conflict',
    410 => 'Gone',
    411 => 'Length Required',
    412 => 'Precondition Failed',
    413 => 'Request Entity Too Large',
    414 => 'Request-URI Too Long',
    415 => 'Unsupported Media Type',
    416 => 'Requested Range Not Satisfiable',
    417 => 'Expectation Failed',
    418 => 'I\'m a teapot',
    422 => 'Unprocessable Entity',
    423 => 'Locked',
    424 => 'Failed Dependency',
    425 => 'Unordered Collection',
    426 => 'Upgrade Required',
    449 => 'Retry With',
    450 => 'Blocked by Windows Parental Controls',
    500 => 'Internal Server Error',
    501 => 'Not Implemented',
    502 => 'Bad Gateway',
    503 => 'Service Unavailable',
    504 => 'Gateway Timeout',
    505 => 'HTTP Version Not Supported',
    506 => 'Variant Also Negotiates',
    507 => 'Insufficient Storage',
    509 => 'Bandwidth Limit Exceeded',
    510 => 'Not Extended'
);

Normal array version

$http_codes = array(
    array(100, 'Continue'),
    array(101, 'Switching Protocols'),
    array(102, 'Processing'),
    array(200, 'OK'),
    array(201, 'Created'),
    array(202, 'Accepted'),
    array(203, 'Non-Authoritative Information'),
    array(204, 'No Content'),
    array(205, 'Reset Content'),
    array(206, 'Partial Content'),
    array(207, 'Multi-Status'),
    array(300, 'Multiple Choices'),
    array(301, 'Moved Permanently'),
    array(302, 'Found'),
    array(303, 'See Other'),
    array(304, 'Not Modified'),
    array(305, 'Use Proxy'),
    array(306, 'Switch Proxy'),
    array(307, 'Temporary Redirect'),
    array(400, 'Bad Request'),
    array(401, 'Unauthorized'),
    array(402, 'Payment Required'),
    array(403, 'Forbidden'),
    array(404, 'Not Found'),
    array(405, 'Method Not Allowed'),
    array(406, 'Not Acceptable'),
    array(407, 'Proxy Authentication Required'),
    array(408, 'Request Timeout'),
    array(409, 'Conflict'),
    array(410, 'Gone'),
    array(411, 'Length Required'),
    array(412, 'Precondition Failed'),
    array(413, 'Request Entity Too Large'),
    array(414, 'Request-URI Too Long'),
    array(415, 'Unsupported Media Type'),
    array(416, 'Requested Range Not Satisfiable'),
    array(417, 'Expectation Failed'),
    array(418, 'I\'m a teapot'),
    array(422, 'Unprocessable Entity'),
    array(423, 'Locked'),
    array(424, 'Failed Dependency'),
    array(425, 'Unordered Collection'),
    array(426, 'Upgrade Required'),
    array(449, 'Retry With'),
    array(450, 'Blocked by Windows Parental Controls'),
    array(500, 'Internal Server Error'),
    array(501, 'Not Implemented'),
    array(502, 'Bad Gateway'),
    array(503, 'Service Unavailable'),
    array(504, 'Gateway Timeout'),
    array(505, 'HTTP Version Not Supported'),
    array(506, 'Variant Also Negotiates'),
    array(507, 'Insufficient Storage'),
    array(509, 'Bandwidth Limit Exceeded'),
    array(510, 'Not Extended')
);
Svisstack
+1 Though it would be easier to have an associative array (ie. `$http_codes = array(100 => 'Continue', ..., 510 => 'Not Extended');`
wimvds
Out of subject but, won't that be easier to read and use this way : `$http_codes = array(100=> 'Continue', 101 => 'Switching Protocols',...);` (I know I may be wrong but I need to know)
Chouchenos
@wimvds: fixed.
Svisstack