php提示:Call to undefined function curl_init
來源:程序員人生 發布時間:2013-11-01 08:35:47 閱讀次數:2642次
我要利用curl函數進行數據采集時發現提示Call to undefined function curl_init錯誤了,后來從官網了解到因為curl默認不是php開啟的函數,我們需要手工打開哦,下面我來給大家介紹開啟curl函數,例:
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
- $response = curl_exec($ch);
- if(curl_errno($ch)){
- print curl_error($ch);
- }
- curl_close($ch);
- 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
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈