上記記事より転載
$context = stream_context_create(array(
'http' => array('ignore_errors' => true)
));
$response = file_get_contents('http://example.com/', false, $context);
preg_match('/HTTP\/1\.[0|1|x] ([0-9]{3})/', $http_response_header[0], $matches);
$status_code = $matches[1];
switch ($status_code) {
case '200':
// 200の場合
break;
case '404':
// 404の場合
break;
default:
break;
}
コメントでいただいた助言
・この関数はデフォルトで 200 以外は FALSE を返します
・ignore_errors と @ を両方付ける意味はありません