Discussion on the curl opening problem of PHP _php skills

Source: Internet
Author: User
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);
}

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.