In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to understand the curl opening problem of PHP". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Today, I am doing a login function of Sina. The PHP SDK provided by Sina needs to use the curl_init () function. When debugging, I can't find the method of curl_init ().
After searching, we know that we need to open the php extension of curl, so what is curl? What can I do?
In short, 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 thieves are rampant, causing some sites to make domain name restrictions, so these file () functions are inefficient or even invalid.
If you use curl to optimize it, you can have some powerful and flexible functions such as forms, cookie, validation and so on.
To turn on curl
1. Output phpinfo under the localhost site to detect the location of the php.ini
(because when I opened CURL, I configured php.ini in the installation directory of php, but it did not take effect. Later, I checked phpinfo to know that php.ini is in apache.
Has been redirected by me in the configuration file)
two。 Open the php.ini file, search for PHP _ curl.dll, find it, delete the previous ";", and restart apache
3. If the test still cannot find curl_init (), change the php_curl.dll in the ext directory in the php directory and the libeay32.dll,php5ts.dll,ssleay32.dll in the php directory
Copy to c:\ windows\ system32 and restart apache
Verify whether the curl extension is enabled, which can be found in phpinfo ()
You can also use program verification
The copy code is as follows:
/ / 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 get 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)
}
This is the end of the content of "how to understand the curl opening problem of PHP". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.