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