Home
Sign Up
Sign In
BBOO's recent timeline updates
BBOO
V2EX member #126880, joined on 2015-07-13 10:00:34 +08:00
BBOO
提问
技术话题
好玩
工作信息
交易信息
城市相关
php 如何高效率的判断远程图片是否存在
PHP
•
BBOO
•
Jun 23, 2016
• Lastly replied by
lslqtz
19
»
More topics by BBOO
BBOO's recent replies
Jun 20, 2016
Replied to a topic by
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;
}
}
»
More replies by BBOO
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
2678 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms ·
UTC 14:38
·
PVG 22:38
·
LAX 07:38
·
JFK 10:38
♥ Do have faith in what you're doing.
❯