Answers for "php curl code 0"

PHP
5

php curl print status

$url = 'http://www.example.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true);    // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true);    // we don't need body
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo 'HTTP code: ' . $httpcode;
Posted by: Guest on March-02-2020
2

php curl timeout

curl_setopt($ch, CURLOPT_TIMEOUT, 5); //timeout in seconds
#curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000); //timeout in Milliseconds
Posted by: Guest on March-05-2021

Browse Popular Code Answers by Language