好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php提示:Call to undefined function curl_init - php函数

php提示:Call to undefined function curl_init

我要利用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 

查看更多关于php提示:Call to undefined function curl_init - php函数的详细内容...

  阅读:44次