Home  >  Article  >  Backend Development  >  About curl opening problem in PHP_PHP tutorial

About curl opening problem in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:35637browse

Today I am working on a Sina login function. The curl_init() function needs to be used in the PHP SDK provided by Sina. When debugging, it reports that the curl_init() method cannot be found.
After searching, I learned that I need to enable the php extension of curl. So what is curl? What can be done?
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 thief programs are flooding, causing some sites to do Without domain name restrictions, these file() functions are inefficient or even invalid.
If you use curl to optimize it, you can achieve powerful and flexible functions such as forms, cookies, and verification.
Steps to enable curl
1. Output phpinfo under the localhost site to detect the location of php.ini
(Because when I enable CURL, I configure php in the php installation directory. ini, the result never took effect. After checking phpinfo, I found out that php.ini was redirected by me in the configuration file of apache
)
2. Open the php.ini file, search for php_curl.dll, and delete it after finding it. ";" in front, restart apache
3. If the test still cannot find curl_init(), change php_curl.dll in the ext directory under the php directory, and libeay32.dll, php5ts.dll under the php directory, ssleay32.dll
Copy to c:windowssystem32, restart apache
Verify whether the curl extension is enabled, you can search it in phpinfo()
You can also use the program to verify

// 1. Initialization
$ch = curl_init();
// 2. Setting 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 content of the HTML document
$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);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/750419.htmlTechArticleToday I am making a Sina login function. The curl_init() function needs to be used in the PHPSDK provided by Sina. During debugging Sometimes it is reported that the curl_init() method cannot be found. After searching, I learned that curl needs to be enabled...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn