check HTTP Status Code Checker of url

In this post we will show you how to check HTTP Status Code Checker of url. we can also check status code, response headers, redirect location and redirect chain of a HTTP connection Of url/link. In this post we can check url, image url, pdf url, xml url. It is very easy method for HTTP Status Code Checker of url.

function check_url_exists($your_url, array $set_options = array()) {
if (empty($your_url)) {
throw new Exception('URL is empty');
}

// list of HTTP status codes
$http_status_codes = array(
100 => 'Continue', // status codes 100
101 => 'Switching Protocols', // status codes 101
102 => 'Processing', // status codes 102
200 => 'OK', // status codes 200
201 => 'Created', // status codes 201
202 => 'Accepted', // status codes 202
203 => 'Non-Authoritative Information', // status codes 203
204 => 'No Content', // status codes 204
205 => 'Reset Content', // status codes 205
206 => 'Partial Content', // status codes 206
207 => 'Multi-Status', // status codes 207
208 => 'Already Reported', // status codes 208
226 => 'IM Used', // status codes 226
300 => 'Multiple Choices', // status codes 300
301 => 'Moved Permanently', // status codes 301
302 => 'Found', // status codes 302
303 => 'See Other', // status codes 303
304 => 'Not Modified', // status codes 304
305 => 'Use Proxy', // status codes 305
306 => 'Switch Proxy', // status codes 306
307 => 'Temporary Redirect', // status codes 307
308 => 'Permanent Redirect', // status codes 308
400 => 'Bad Request', // status codes 400
401 => 'Unauthorized', // status codes 401
402 => 'Payment Required', // status codes 402
403 => 'Forbidden', // status codes 403
404 => 'Not Found', // status codes 404
405 => 'Method Not Allowed', // status codes 405
406 => 'Not Acceptable', // status codes 406
407 => 'Proxy Authentication Required', // status codes 407
408 => 'Request Timeout', // status codes 408
409 => 'Conflict', // status code 409
410 => 'Gone', // status codes 410
411 => 'Length Required', // status codes 411
412 => 'Precondition Failed', // status codes 412
413 => 'Payload Too Large', // status codes 413
414 => 'Request-URI Too Long', // status codes 414
415 => 'Unsupported Media Type', // status codes 415
416 => 'Requested Range Not Satisfiable', // status codes 416
417 => 'Expectation Failed', // status codes 417
418 => 'I\'m a teapot', // status codes 418
422 => 'Unprocessable Entity', // status codes 422
423 => 'Locked', // status codes 423
424 => 'Failed Dependency', // status codes 424
425 => 'Unordered Collection', // status codes 425
426 => 'Upgrade Required', // status codes 426
428 => 'Precondition Required', // status codes 428
429 => 'Too Many Requests', // status codes 429
431 => 'Request Header Fields Too Large', // status codes 431
449 => 'Retry With', // status codes 449
450 => 'Blocked by Windows Parental Controls', // status codes 450
500 => 'Internal Server Error', // status codes 500
501 => 'Not Implemented', // status codes 501
502 => 'Bad Gateway', // status codes 502
503 => 'Service Unavailable', // status codes 503
504 => 'Gateway Timeout', // status codes 504
505 => 'HTTP Version Not Supported', // status codes 505
506 => 'Variant Also Negotiates', // status codes 506
507 => 'Insufficient Storage', // status codes 507
508 => 'Loop Detected', // status codes 508
509 => 'Bandwidth Limit Exceeded', // status codes 509
510 => 'Not Extended', // status codes 510
511 => 'Network Authentication Required',  // status codes 511
599 => 'Network Connect Timeout Error' // status codes 599
);

$result_return = "";
$connection = curl_init($your_url);
curl_setopt($connection, CURLOPT_NOBODY, true);
curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);

if (isset($set_options['timeout'])) {
$timeout = (int) $set_options['timeout'];
curl_setopt($connection, CURLOPT_TIMEOUT, $timeout);
}

curl_exec($connection);
$returned_status_code = curl_getinfo($connection, CURLINFO_HTTP_CODE);
curl_close($connection);

if (array_key_exists($returned_status_code, $http_status_codes)) {
$result_return = " URL : '{$your_url}' - Error code: {$returned_status_code} - Definition: {$http_status_codes[$returned_status_code]}";
} else {
$result_return = "'{$your_url}' does not exist";
}
return $result_return;
}

// add your url.
$your_url  = "http://www.onlinecode";

var_dump (check_url_exists($your_url));

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  61  =  69

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US