Today in doing a Sina login function, Sina provides the PHP SDK needs to use the Curl_init () function, in the debugging time can not find the Curl_init () method.
After the search to know that you need to open curl PHP expansion, then what is curl? What can I do?
Simple introduction, when we need to grasp the data of a website, you can use the file (), file_get_contents (), such as Web page reading function, because too many thieves program overflow, causing some sites to do domain name restrictions, so that is the file () function inefficient or even ineffective.
If you use curl to optimize the words can be a number of forms, cookies, validation and other functions of the powerful, flexible effect.
To open the Curl procedure
1. In the localhost site output phpinfo, in order to detect the location of php.ini
(because I opened the curl, is in the PHP installation directory configuration php.ini, the result has not been effective, and then checked the phpinfo just know php.ini in Apache
I redirected the configuration file.
2. Open php.ini file, search Php_curl.dll, find and remove the front ";", restart Apache
3. If the test is still unable to find Curl_init (), will be in the PHP directory in the ext directory of Php_curl.dll, and PHP directory under the Libeay32.dll,php5ts.dll,ssleay32.dll
Copy to C:\Windows\System32, restart Apache
Verify that the curl extension is open and can be found in phpinfo ()
You can also use program validation
Copy Code code as follows:
1. Class
$ch = Curl_init ();
2. Setting options, including URLs
curl_setopt ($ch, Curlopt_url, "http://www.tupc1028.com");
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_header, 0);
3. Execute and get the contents of the HTML document
$output = curl_exec ($ch);
4. Release Curl handle
Curl_close ($ch);
$output = curl_exec ($ch);
if ($output = = FALSE) {
echo "CURL Error:". Curl_error ($ch);
}