note 82300 added to function.curl-setopt
| From: | johnfactorial at osu1 dot php dot net | Date: | Fri, 04 Apr 2008 16:22:51 +0000 |
| Subject: | note 82300 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137932@lists.php.net to get a copy of this message | ||
Clarification for the CURLOPT_NOBODY option: by excluding the body from your request, you're
effectively making a HEAD request. Use the CURLOPT_NOBODY option to return only the headers in the
remote response.
Example:
function check_url($url) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_HEADER, 1); // get the header
curl_setopt($c, CURLOPT_NOBODY, 1); // and *only* get the header
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // get the response as a string from curl_exec(),
rather than echoing it
curl_setopt($c, CURLOPT_FRESH_CONNECT, 1); // don't use a cached version of the url
if (!curl_exec($c)) { return false; }
$httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE);
return ($httpcode < 400);
}
----
Server IP: 209.41.74.194
Probable Submitter: 63.172.193.57
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/82300
Del: integrated -- https://master.php.net/note/delete/82300/integrated
Del: useless -- https://master.php.net/note/delete/82300/useless
Del: bad code -- https://master.php.net/note/delete/82300/bad+code
Del: spam -- https://master.php.net/note/delete/82300/spam
Del: non-english -- https://master.php.net/note/delete/82300/non-english
Del: in docs -- https://master.php.net/note/delete/82300/in+docs
Del: other reasons-- https://master.php.net/note/delete/82300
Reject -- https://master.php.net/note/reject/82300
Search -- https://master.php.net/manage/user-notes.php