BBOO 最近的时间轴更新
BBOO

BBOO

V2EX 第 126880 号会员,加入于 2015-07-13 10:00:34 +08:00
BBOO 最近回复了
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   ·   我们的愿景   ·   实用小工具   ·   898 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 20:05 · PVG 04:05 · LAX 13:05 · JFK 16:05
Developed with CodeLauncher
♥ Do have faith in what you're doing.