V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  BBOO  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2016-06-20 14:09:23 +08:00
回复了 BBOO 创建的主题 PHP php 如何高效率的判断远程图片是否存在
感谢各位,由于这个头像地址 app 也在调用,考虑到旧版兼容性,客户端无法做处理。
nginx 改 404 的方法,运维说用了什么云, nginx 改不了。
用了 @lslqt2z 、 @takwai 的方法,加了个超时时间,测试了响应速度还不错,感谢!!!
以下是改后的代码:
function exit_file($url){
$opts=array(
'http'=>array(
'method'=>'HEAD',
'timeout'=>2
));
file_get_contents($url,false,stream_context_create($opts));
if ($http_response_header[0] == 'HTTP/1.1 200 OK') {
return true;
} else {
return false;
}
}
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1190 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 10ms · UTC 18:10 · PVG 02:10 · LAX 11:10 · JFK 14:10
Developed with CodeLauncher
♥ Do have faith in what you're doing.