Created
December 2, 2014 07:02
-
-
Save violetyk/97eed8a62e7aa9a133db to your computer and use it in GitHub Desktop.
file_get_contents()エラー判定
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$context = stream_context_create(array( | |
'http' => array( | |
'ignore_errors' => true, | |
'header' => 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', | |
) | |
)); | |
$response = file_get_contents($url, false, $context); | |
$pos = strpos($http_response_header[0], '200'); | |
if ($pos === false) { | |
echo 'error'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment