note 99110 added to function.curl-exec
| From: | (dv-at-rb-no) | Date: | Wed, 28 Jul 2010 11:02:41 +0000 |
| Subject: | note 99110 added to function.curl-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171184@lists.php.net to get a copy of this message | ||
<?php
// URL_GetStatus by Dmitry K Valberg // dv at rb.no
// Checks URL and returns easy to use HTTP status codes.
//
// Will return on error:
// 501 - URL syntax error, URL not valid.
// 503 - Timeout, connection error etc.
//
// If url is valid and curl connected to server,
// real HTTP code will be returned.
function URL_GetStatus($url) {
$_r = 501;
if (filter_var($url, FILTER_VALIDATE_URL) != false) {
try {
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_URL, $url);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_FAILONERROR, 1);
@curl_setopt($ch, CURLOPT_NOBODY, 1);
@curl_setopt($ch, CURLOPT_TIMEOUT, 5);
@curl_exec($ch);
$info = @curl_getinfo($ch);
curl_close ($ch);
if (($info['http_code'] > 100)) $_r = $info['http_code'];
} catch (Exception $e) {
$_r = 503;
}
}
return $_r;
}
?>
----
Server IP: 85.19.212.230
Probable Submitter: 193.215.6.253
----
Manual Page -- http://www.php.net/manual/en/function.curl-exec.php
Edit -- https://master.php.net/note/edit/99110
Del: integrated -- https://master.php.net/note/delete/99110/integrated
Del: useless -- https://master.php.net/note/delete/99110/useless
Del: bad code -- https://master.php.net/note/delete/99110/bad+code
Del: spam -- https://master.php.net/note/delete/99110/spam
Del: non-english -- https://master.php.net/note/delete/99110/non-english
Del: in docs -- https://master.php.net/note/delete/99110/in+docs
Del: other reasons-- https://master.php.net/note/delete/99110
Reject -- https://master.php.net/note/reject/99110
Search -- https://master.php.net/manage/user-notes.php