PHP CURL GET HTTP CODE


$url ='http://www.baidu.com';
$millisecond=100;

function get_url_status($url,$millisecond=100)
{
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_TIMEOUT_MS,$millisecond);
    curl_setopt($ch,CURLOPT_NOBODY,true);
    curl_exec($ch);
    $rt = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    return $rt;
}

echo get_url_status($url,$millisecond);


你可能感兴趣的:(PHP CURL GET HTTP CODE)