How to enable PHP curl

Source: Internet
Author: User
The curl_init () function is required in the PHPSDK provided by Sina. when debugging, it is reported that the curl_init () method cannot be found, the following describes how to enable curl. Today, we are working on a Sina login function. The php sdk provided by Sina needs to use the curl_init () function. during debugging, we cannot find curl_init ().
After searching, I learned that the php extension of curl needs to be enabled. what is curl? What can we do?
For a brief introduction, when we need to capture the data information of a website, we can use file (), file_get_contents () and other web page reading functions, because too many thieves program flood, as a result, some websites impose domain name restrictions, so that these file () functions are inefficient or even ineffective.
If you use curl for optimization, you can perform some forms, cookies, verification, and other functions with powerful and flexible functions.

To enable curl

1. output phpinfo at The localhost site to check the location of php. ini.
(When I started CURL, I configured php. ini in the php installation directory, but the result never took effect. later I checked phpinfo to find out that php. ini was running on apache.
Is redirected to the configuration file)
2. open the php. ini file, search for php_curl.dll, find and delete the previous ";", and restart apache.
3. if you still cannot find curl_init () in the test, set the php_curl.dll in the ext directory under the php directory to libeay32.dll, php5ts. dll, and ssleay32.dll under the php directory.
Copy to c: \ windows \ system32 and restart apache
Verify whether curl extension is enabled. you can find it in phpinfo ().
You can also use the program for verification.

The code is as follows:


// 1. initialization
$ Ch = curl_init ();
// 2. set options, including URL
Curl_setopt ($ ch, CURLOPT_URL, "http://www.tupc1028.com ");
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
// 3. execute and obtain the HTML document content
$ Output = curl_exec ($ ch );
// 4. release the curl handle
Curl_close ($ ch );
$ Output = curl_exec ($ ch );
If ($ output = FALSE ){
Echo "cURL Error:". curl_error ($ ch );
}

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.