您需要检查HTTP响应代码:
function get_http_response_pre($url) { $headers = get_headers($url); return substr($headers[0], 9, 3);}if(get_http_response_pre('http://somenotrealurl.com/notrealpage') != "200"){ echo "error";}else{ file_get_contents('http://somenotrealurl.com/notrealpage');}


