note 77167 added to function.curl-exec
| From: | shanto at ultimawebsolutions dot com | Date: | Fri, 17 Aug 2007 16:01:54 +0000 |
| Subject: | note 77167 added to function.curl-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129563@lists.php.net to get a copy of this message | ||
A function to retrieve the status code of an HTTP request using CURL:
function getHttpResponseCode($url)
{
$ch = @curl_init($url);
@curl_setopt($ch, CURLOPT_HEADER, TRUE);
@curl_setopt($ch, CURLOPT_NOBODY, TRUE);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$status = array();
$response = @curl_exec($ch);
preg_match('/HTTP\/.* ([0-9]+) .*/', $response, $status);
return $status[1];
}
----
Server IP: 203.220.0.234
Probable Submitter: 122.102.57.254 (proxied: 122.102.57.254)
----
Manual Page -- http://www.php.net/manual/en/function.curl-exec.php
Edit -- https://master.php.net/note/edit/77167
Del: integrated -- https://master.php.net/note/delete/77167/integrated
Del: useless -- https://master.php.net/note/delete/77167/useless
Del: bad code -- https://master.php.net/note/delete/77167/bad+code
Del: spam -- https://master.php.net/note/delete/77167/spam
Del: non-english -- https://master.php.net/note/delete/77167/non-english
Del: in docs -- https://master.php.net/note/delete/77167/in+docs
Del: other reasons-- https://master.php.net/note/delete/77167
Reject -- https://master.php.net/note/reject/77167
Search -- https://master.php.net/manage/user-notes.php