Home >Backend Development >PHP Tutorial >php curl_init function usage_PHP tutorial

php curl_init function usage_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:52:13927browse

php curl_init function usage

First of all, I turned on the extension=php_curl.dll function in php.ini in Cwindows, and then restarted apapche. The following is what I wrote to capture the information of PHP in Baidu:
//Initialize curl
$ch = curl_init() or die (curl_error());
echo "Test it";
//Set URL parameters
curl_setopt($ch,CURLOPT_URL,"http://www.baidu.com/s?wd=php");
//Require CURL to return data
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
//Execute request
$result = curl_exec($ch) or die (curl_error());
//Get the returned result and display
echo $result;
echo curl_error($ch);
//Close CURL
curl_close($ch);
?>
But why didn't it respond? There is no test text. If I put echo "test"; on the first line, it can be output. I guess the curl_init() function has not been run yet!

Check if there is CURL extension support in PHP’s phpinfo()!

Copy php_curl.dll to c:windows and c:windowssystem32 and restart apache
Try it later

It is not the file php_curl.dll
Copy libeay32.dll and ssleay32.dll in the php directory to c:windowssystem32 and restart apache

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632492.htmlTechArticlephp curl_init function usage First, in php.ini in Cwindows, I turned on the extension=php_curl.dll function , and then restarted apapche. The following is the information I wrote to capture PHP in Baidu...
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