Windows 7中的XAMPP 1.7.7不使用curl返回任何内容 [英] XAMPP 1.7.7 in Windows 7 returns nothing using curl
问题描述
我在使用时遇到问题
curl_getinfo
我已经检查过 curl扩展的 php.ini ,一切似乎都很好, phpinfo (); ,启用curl,所以我知道它不应该有任何问题。
I have already checked the php.ini for curl extension and everything seems to be fine and inside phpinfo();, curl is enable so I know that It shouldn't have any problem.
我的web服务器。这是我的本地机器与 XAMPP 1.7.7 ,给我一个困难的时刻。这可能是因为我的笔记本电脑的安全设置?
This function runs fine in my web server. It is my local machine with XAMPP 1.7.7 that gives me a hard time. Could this be because of firwall settings of my laptop?
请注意,jpg文件存在于Amazon s3 URL中,我已经在浏览器上检查了Amazon网址显示图像...
Please note that the jpg file exists inside the Amazon s3 URL and I have checked the Amazon URL on the browser and it shows the image...
///////////////////编辑///////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// /////////////////////
/////////////////// Edited //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
这里是我的代码,它是类中的一个函数或方法:
here is my code which is a function or method inside a class:
public function pictureExistence($id){
$url = AMAZON_S3_URL . $id . '.jpg';
//var_dump($url);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
//var_dump($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//var_dump($code);
if($code == 200){
$status = true;
}else{
$status = false;
}
curl_close($ch);
return $status;
}
推荐答案
无论是为你工作。已在 XAMPP 1.7.7 上测试可正常工作。
Try the following code and check whether it's working for you. It has been tested to work fine on XAMPP 1.7.7 .
<?php
// Create a curl handle
$ch = curl_init('http://www.yahoo.com/');
// Execute
curl_exec($ch);
// Check if any error occured
if(!curl_errno($ch))
{
$info = curl_getinfo($ch);
echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
}
// Close handle
curl_close($ch);
?>
这篇关于Windows 7中的XAMPP 1.7.7不使用curl返回任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!