Home > php教程 > php手册 > php提示:Call to undefined function curl_init

php提示:Call to undefined function curl_init

WBOY
Release: 2016-06-13 09:56:55
Original
802 people have browsed it

我要利用curl函数进行数据采集时发现提示Call to undefined function curl_init错误了,后来从官网了解到因为curl默认不是php开启的函数,我们需要手工打开哦,下面我来给大家介绍开启curl函数。

 代码如下 复制代码

$ch = curl_init(); //初始化curl
curl_setopt($ch, CURLOPT_URL, $url);//设置链接
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//设置HTTP头
curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);//POST数据
$response = curl_exec($ch);//接收返回信息
if(curl_errno($ch)){//出错则显示错误信息
 print curl_error($ch);
}
curl_close($ch); //关闭curl链接
echo $response;//显示返回信息

结果出现

Call to undefined function curl_init

解决方法如下:

1.打开php.ini,开启extension=php_curl.dll

2.检查php.ini的extension_dir值是哪个目录,检查有无php_curl.dll,没有的请下载php_curl.dll,再把php目录中的libeay32.dll,ssleay32.dll拷到c:windowssystem32里面

修改之后还有问题啊

在httpd.conf文件中加上:

LoadFile 动态链接库的完整路径

比如,此处php需要扩展curl,因此解决方法就是在httpd.conf文件中加上:

LoadFile d:/php/libeay32.dll
LoadFile d:/php/ssleay32.dll

这样就解决了

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template