平成30/ 2018-10-23 19:46
PHP/get_headers

___ HTTPヘッダを取得できる。
$header = get_headers($url);


___ リンク切れチェックは以下の感じ。
    if(
    !$header = get_headers($url) or
    !is_array($header)
    ){
        $refuse_li[]   = $url;
        $refuse_log[] = $url;
        $refuse_log[] = "";
        continue;
    }
    $flg = false;
    foreach($header as $val){
        $val = trim($val);
        if(
        preg_match('/^HTTP\/[0-9]+[0-9\.]+ +200 +OK$/ui', $val)
        ){
            $flg = true;
        }
    }
    if(
    !$flg
    ){
        $refuse_li[] = $url;
        //echo "{$url}\n";
        //print_r($header);
        $refuse_log[] = $url;
        $refuse_log[] = var_export($header, true);
        $refuse_log[] = "";
    }


___ Thanks.
get_headers
http://php.net/manual/ja/function.get-headers.php