Php prompts Calltoundefinedfunctioncurl_init () _ PHP through the curl function.

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.