First, I opened the extensionphp_curldll function in phpini in Cwindows, and then restarted apapche. The following is what I wrote to capture PHP information in Baidu:
Php curl_init function usage
First, in php. ini in C \ windows, I opened the extension = php_curl.dll function, and then restarted apapche. The following is what I wrote to capture PHP information in Baidu:
-
- // Initialize curl
- $ Ch = curl_init () or die (curl_error ());
- Echo "test ";
- // Set URL parameters
- Curl_setopt ($ ch, CURLOPT_URL, "http://www.baidu.com/s? Wd = php ");
- // Request that CURL return data
- Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
- // Execute the request
- $ Result = curl_exec ($ ch) or die (curl_error ());
- // Obtain the returned result and display it
- Echo $ result;
- Echo curl_error ($ ch );
- // Disable CURL
- Curl_close ($ ch );
- ?>
But why didn't we respond? No text for the test. if I put echo "test" on the first line, the output will be available. I guess the curl_init () function is not running yet!
Check whether CURL extension support is available in PHP phpinfo! Copy php_curl.dll to c: \ windows \ and c: \ windows \ system32, restart apache, and try again. instead of the php_curl.dll file, copy libeay32.dll and ssleay32.dll in the php directory to c: restart apache in \ windows \ system32.