教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php提示:Call to undefined function curl_init

php提示:Call to undefined function curl_init

发布时间:2018-11-30   编辑:jiaochengji.com
教程集为您提供php提示:Call to undefined function curl,init等资源,欢迎您收藏本站,我们将为您提供最新的php提示:Call to undefined function curl,init资源
我要利用curl函数进行数据采集时发现提示Call to undefined function curl_init错误了,后来从官网了解到因为curl默认不是php开启的函数,我们需要手工打开哦,下面我来给大家介绍开启curl函数。

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy3904')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3904>

$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

这样就解决了

您可能感兴趣的文章:

[关闭]
~ ~