[英]cUrl always return false
I'm using curl
to show pics in a B2B catalogue from a website $img
. 我正在使用
curl
在网站$img
的B2B目录中显示$img
。 I cannot understand why it returns always false (It means that 我不明白为什么它总是返回false(这意味着
if ($this->checkExist($img))
return $img;
return 'http://images/no-image.jpg';
it is always returning no-image.jpg 它总是返回no-image.jpg
My curl code is the following 我的卷曲代码如下
private function checkExist($pic)
{
$picNoSpaces = str_replace(' ', '%20', $pic);
$ch = curl_init($picNoSpaces);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_URL,$picNoSpaces);
// don't download content
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (200 <= $retcode and 300 > $retcode)
return true;
return false;
}
Could someone help me? 有人可以帮我吗? Thanks!
谢谢!
$retcode
为0,所以这就是为什么我总是返回false但却无法返回的原因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.