Home  >  Article  >  Backend Development  >  Discussion on the problem of curl opening in PHP_PHP tutorial

Discussion on the problem of curl opening in PHP_PHP tutorial

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

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 is reported 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. Due to the proliferation of too many thief programs, some sites have implemented domain name restrictions. , thus making these file() functions 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 open curl

1. Output phpinfo under the localhost site to detect the location of php.ini
(Because when I open CURL, it is in php I configured php.ini in the installation directory, but 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 and search for php_curl .dll, delete the preceding ";" after finding it, and 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 under the php directory. dll, php5ts.dll, ssleay32.dll
Copy to c:windowssystem32, restart apache
Verify whether the curl extension is turned on, you can search it in phpinfo()
You can also use the program to verify

Copy code The code is as follows:

// 1. Initialization
$ch = curl_init();
// 2. Settings 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/750853.htmlTechArticleToday I am working on a Sina login function. The curl_init() function needs to be used in the PHP SDK provided by Sina. During debugging When reporting, 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