获取网络URL http状态头

function checkCode($url)
{
    $ch = curl_init();

    $timeout = 1;

    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_HEADER, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);

    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_exec($ch);

    $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE);

    curl_close($ch);

    return $httpcode;
}

 

获取网络URL http状态头

上一篇:使用对象存储oss实现图片上传


下一篇:Netty服务开发