CURLOPT_URL改成http://localhost/hello.html,正常工作显示hello的内容,但访问外面的网站比如google sina,都不行,curl_exec为空,哪里出了问题?$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
var_dump(curl_exec($ch));
curl_close($ch);
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
var_dump(curl_exec($ch));
curl_close($ch);
(连接google,因为我们的地址会被转移到google.com.hk,所以才302的)
http://www.baidu.com/没问题
http://www.sina.com.cn/没问题