使用不存在的fopen
访问xml文件时,我们得到
无法打开流:HTTP 请求失败!
但这需要 30 秒。如何在找不到文件后立即或短暂返回此错误。
另外,为什么找不到文件时,Apache会扫描很多端口?
我认为是
这样的,你必须使用 fopen 本身来检查它是否存在,
function fileExists($path){
return (@fopen($path,"r")==true);
}
if(fileExists('http://example.com/test/file.xml'))
{
echo "exists";
}
else
{
echo "not_exist";
}