在使用PHP 的Curl方法时出现了以下错误
可能的解决办法:
- 在php.ini 中确保 启用了php_curl.dll组件
- 确保PHP版本 (PHP 4 >= 4.0.2, PHP 5, PHP 7)
/** * @Author: HTL * @Email: Huangyuan413026@163.com * @DateTime: 2016-12-28 11:36:03 * @Description: 获取远程内容 */ function _file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $data = curl_exec($ch); curl_close($ch); return $data; }
print_r(_file_get_contents_curl("http://baidu.com"));
参考: