PHP uses the Curl function to prompt the call to undefined function curl_init () _php Tutorial

Source: Internet
Author: User
Yesterday when I was using curl to write an API interface, I found that when I ran the Curl function, I was prompted by the call-to-undefined function curl_init () error, which, from the wrong point of view, did not define CURL_INIT (). It was later learned that this function must open a file in PHP, as follows.

Program code that's what I wrote.

The code is as follows Copy Code

?? Php
Initialize a CURL object
$curl = Curl_init ();

Set the URL you need to crawl
curl_setopt ($curl, Curlopt_url, ' http://www.bKjia.c0m ');

Set Header
curl_setopt ($curl, Curlopt_header, 1);

Sets the curl parameter, which requires the result to be saved to a string or output to the screen.
curl_setopt ($curl, Curlopt_returntransfer, 1);

Run Curl, request a Web page
$data = curl_exec ($curl);

Close URL Request
Curl_close ($curl);

Show the data obtained
Var_dump ($data);

The results suggest: call to undefined function curl_init (), and then Baidu a number of solutions, we can refer to.


Modify the configuration under Windows+apache:

1. Modify the php.ini, remove the semicolon in front of the Extension=php_curl.dll
2. Copy Libeay32.dll, Ssleay32.dll (C:APPSERVPHP5) two files to system32 directory
3. Restart Apache (services.msc) to


Linux+apache Solution:

You need to install the Curl package. If you're using Ubuntu, open the new Rieter Package Manager to search for curl and install curl

http://www.bkjia.com/PHPjc/632132.html www.bkjia.com true http://www.bkjia.com/PHPjc/632132.html techarticle yesterday when I was using curl to write an API interface, I found that when I ran the Curl function, I was prompted by the call to undefined function curl_init () error, from the error that there is no curl_init () function defined, after ...

  • Related Article

    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.