Last active
August 29, 2015 13:56
-
-
Save dhrrgn/8851234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gets the HTTP status code for the given URL. | |
* | |
* @param string $url The URL to check. | |
* @return int | |
*/ | |
function url_http_status($url) { | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_NOBODY, true); | |
curl_exec($ch); | |
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
return $status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment