Php prompts Calltoundefinedfunctioncurl_init () by using the curl function (). Yesterday when I used curl to write an api, I found that the Calltoundefinedfunctioncurl_init () error was prompted when running the curl function. from the error, the curl_init () function is not defined, when I used curl to write an api interface yesterday, I found that the Call to undefined function curl_init () error was prompted when running the curl function. from the error, the curl_init () function is not defined, later I learned that this function must open a file in php. the specific method is as follows.
I wrote the program code like this.
The code is as follows: |
|
?? Php // Initialize a cURL object $ Curl = curl_init (); // Set the URL you want to capture Curl_setopt ($ curl, CURLOPT_URL, 'http: // www. bKjia. c0m '); // Set the header Curl_setopt ($ curl, CURLOPT_HEADER, 1 ); // Set the cURL parameter to save the result to the string or output to the screen. Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 ); // Run cURL to request the webpage $ Data = curl_exec ($ curl ); // Close the URL request Curl_close ($ curl ); // Display the obtained data Var_dump ($ data ); |
The result shows: Call to undefined function curl_init (). later, Baidu provided some solutions for your reference.
Modify the configuration under windows + apache:
1. modify php. ini and remove the semicolon before extension = php_curl.dll.
2. copy the libeay32.dll and ssleay32.dll (C: AppServphp5) files to the system32 directory.
3. restart Apache (services. msc ).
Linux + apache solution:
Install the curl package. If you use ubuntu, open the new software package manager to search for curl and install curl.
Failed to undefined function curl_init () error. from the error, the curl_init () function is not defined...