【发布时间】:2017-02-17 06:58:16
【问题描述】:
我想要一个 if 语句来检查 php 脚本中的特定错误 错误是这样的
Warning: file_get_contents(http://www.google.com): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\google\index.php on line 196
我的代码
if (file_get_contents('http://www.google.com') === false {
echo 'faild';
}
我只想跳过 404 错误
ps:我没有在谷歌网站上使用我的代码,但我不能写真正的网址
(对不起我的英语不好)
【问题讨论】:
-
您无法使用
file_get_contents(), this function will returntrue` 或false检查 404 错误。您最好的关闭是使用.htacces文件,设置条件ErrorDocument 404 /404.htmlend 然后创建404.html page which will automatically display if a404` 错误发生。
标签: php