次の点を考慮してください。
$url = 'http://psyng.com/u/9716602b';
$headers = get_headers($url, 1);
print_r($headers);
ドメイン psyng.com は解決できないため、このコードの結果は次のようになります。
Warning: get_headers(): php_network_getaddresses: getaddrinfo failed:
No such host is known
そして、スクリプトは実行を停止します。スクリプトの残りの部分を実行し続ける方法はありますか? つまり、エラーをキャッチして次の URL の解決に進む方法はありますか? 次のようなものです:
$url = 'http://psyng.com/u/9716602b';
$headers = get_headers($url, 1);
if ($headers == 'No such host is known') {
// nevermind, just move on to the next URL in the list...
}
else {
// resolve header stuff...
}