PhpCURL collection-

Source: Internet
Author: User
PHP code & nbsp; PHPcode & lt ;? PhpfunctionCurl_http ($ array, $ timeout) {$ res = array (); $ mh = curl_multi_init (); // create multiple curl php CURL collection problems --- please advise
PHP code
PHP code
        
  $ Url) {$ conn [$ k] = curl_init ($ url); curl_setopt ($ conn [$ k], CURLOPT_TIMEOUT, $ timeout ); // Set the timeout value curl_setopt ($ conn [$ k], CURLOPT_USERAGENT, 'mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0 )'); curl_setopt ($ conn [$ k], CURLOPT_MAXREDIRS, 7); // HTTp targeting level curl_setopt ($ conn [$ k], CURLOPT_HEADER, 0); // no header here, ADd block efficiency curl_setopt ($ conn [$ k], CURLOPT_FOLLOWLOCATION, 1); // 302 redirect curl_setopt ($ conn [$ k], CURLO PT_RETURNTRANSFER, 1); curl_multi_add_handle ($ mh, $ conn [$ k]);} // prevent endless loop cpu consumption. do {$ mrc = curl_multi_exec ($ mh, $ active) according to the online statement; // when no data exists, active = true} while ($ mrc = CURLM_CALL_MULTI_PERFORM); // while receiving data ($ active and $ mrc = CURLM_ OK) {// when there is no data or the request is paused, active = true if (curl_multi_select ($ mh )! =-1) {do {$ mrc = curl_multi_exec ($ mh, $ active);} while ($ mrc = CURLM_CALL_MULTI_PERFORM );}} foreach ($ array as $ k =>$ url) {curl_error ($ conn [$ k]); $ res [$ k] = curl_multi_getcontent ($ conn [$ k]); // Get the returned information $ header [$ k] = curl_getinfo ($ conn [$ k]); // return header information curl_close ($ conn [$ k]); // Close the language handle curl_multi_remove_handle ($ mh, $ conn [$ k]); // release resources} curl_multi_close ($ mh); $ endtime = getmicrotime (); $ diff_time = $ endtime-$ startime; return array ('Diff _ time' => $ diff_time, 'Return '=> $ res, 'header' => $ header );} // calculate the current time function getmicrotime () {list ($ usec, $ sec) = explode ("", microtime (); return (float) $ usec + (float) $ sec) ;}// test it. curl 1 URL $ array = array (" http://www.120ask.com/keshi.asp?c=69&a=&l=0&p=1 ",); $ Data = Curl_http ($ array, '1'); // call var_dump ($ data); // Output?>


Libeay32.dll, ssleay32.dll, php5ts. dll, and php_curl.dll are all copied to the system32 directory, and apache is restarted.

PHP. ini enabled CURL

But I still cannot receive an error.

Fatal error: Call to undefined function curl_multi_init () in D: \ wamp \ www \ caiji. php on line 4

------ Solution --------------------
Phpinfo (); check whether there is a curl. if not, it indicates that you have not enabled it successfully (extension = php_curl.dll)
------ Solution --------------------
You have not set the correct path. please try again ~~
------ Solution --------------------
Look at the php configuration file in your phpinfo (), which you modified? For example, if you disable the mysql module and enable phpinfo () to check whether the mysql module is enabled or not, it means that the php configuration file you used is not the one you modified.
------ Solution --------------------
Title party.
------ Solution --------------------
Php CURL collection problems --- please advise
You should ask:
Failed to install curl --- please advise



Have you restarted apache and killed php-cgi.
------ Solution --------------------
This can be used.
PHP code
array(3) { ["diff_time"]=> float(1.0497448444366) ["return"]=> array(1) { [0]=> NULL } ["header"]=> array(1) { [0]=> array(20) { ["url"]=> string(47) "http://www.120ask.com/keshi.asp?c=69&a=&l=0&p=1" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(1) ["namelookup_time"]=> float(1) ["connect_time"]=> float(0) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) } } }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.