When I used the curl function for data collection, I found that the Call to undefined function curl_init error was prompted. Later, I learned from the official website that because curl is not a function enabled by php by default, we need to open it manually, next I will introduce how to enable the curl function.
Example
The Code is as follows: |
Copy code |
$ Ch = curl_init (); // initialize curl Curl_setopt ($ ch, CURLOPT_URL, $ url); // set the link Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // sets whether to return information. Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); // sets the HTTP header Curl_setopt ($ ch, CURLOPT_POST, 1); // set it to POST Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ xml_data); // POST Data $ Response = curl_exec ($ ch); // receives the returned information If (curl_errno ($ ch) {// error message displayed Print curl_error ($ ch ); } Curl_close ($ ch); // close the curl Link Echo $ response; // display the returned information |
Result
Call to undefined function curl_init
The solution is as follows:
1. Open php. ini and enable extension = php_curl.dll.
2. Check the directory in which the extension_dir value of php. ini is and whether php_curl.dll exists. If not, download php_curl.dll and copy libeay32.dll and ssleay32.dll in the php Directory to c: windowssystem32.
There are still problems after modification
Add the following to the httpd. conf file:
Complete path of LoadFile Dynamic Link Library
For example, php needs to expand curl, so the solution is to add the following in the httpd. conf file:
LoadFile d:/php/libeay32.dll
LoadFile d:/php/ssleay32.dll
This solves the problem.