Today, I am working on a Sina login function. The php sdk provided by Sina needs to use the curl_init () function. During debugging, I cannot find the curl_init () method.
After searching, I learned that the php extension of curl needs to be enabled. What is curl? What can we do?
In brief, when we need to capture the data information of a website, we can use file (), file_get_contents () and other webpage reading functions, because
Too many thieves cause domain name restrictions on some sites, which leads to inefficient or even ineffective file () functions.
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.
// 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 );
}