Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7563115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:34:55+00:00 2026-05-30T13:34:55+00:00

$data_struct = array(); $data_struct[][‘opts’] = array( CURLOPT_URL => ‘http://www.yahoo.com/’, CURLOPT_RETURNTRANSFER => true); $data_struct[][‘opts’] =

  • 0
$data_struct = array(); 

$data_struct[]['opts'] = array( CURLOPT_URL => 'http://www.yahoo.com/', CURLOPT_RETURNTRANSFER => true);
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://www.google.com/', CURLOPT_RETURNTRANSFER => true);
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://404.php.net/', CURLOPT_RETURNTRANSFER => true);

//create the multiple cURL handle
$mh = curl_multi_init();

// create and add handles to data structure
foreach ($data_struct as $i => $data){
   $data_struct[$i]['handle'] = curl_init();
   curl_setopt_array($data_struct[$i]['handle'], $data_struct[$i]['opts']);
   curl_multi_add_handle($mh, $data_struct[$i]['handle']);
}  

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);    

} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}    

foreach ($data_struct as $i => $data){
   $row = array();
   $row['httpcode'] = curl_getinfo($data_struct[$i]['handle'] , CURLINFO_HTTP_CODE);
   $row['url'] = $data['opts'][CURLOPT_URL];
   $row['error'] = curl_error($data_struct[$i]['handle']);
   $row['errorno'] = curl_errno($data_struct[$i]['handle']);
   print_r($row);
   echo "\n";       

   curl_multi_remove_handle($mh, $data_struct[$i]['handle']);
   curl_close($data_struct[$i]['handle']);
}

output

Array
(
    [httpcode] => 302
    [url] => http://www.yahoo.com/
    [error] => 
    [errorno] => 0
)

Array
(
    [httpcode] => 302
    [url] => http://www.google.com/
    [error] => 
    [errorno] => 0
)

Array
(
    [httpcode] => 0
    [url] => http://404.php.net/
    [error] => Couldn't resolve host '404.php.net'
    [errorno] => 0
)

In the same situation multi curl returns 0 with curl_errno function despite the fact that curl_error returns error message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:34:57+00:00Added an answer on May 30, 2026 at 1:34 pm

    Provided you have PHP 5.2.x or greater (newer is better here,) I would suggest using curl_multi_info_read(), in this case. (See: curl_multi_info_read() docs.)

    You can see the output of curl_multi_info_read() by putting it near the end of your code (after your echo "\n"; line,) like this:

    var_dump(curl_multi_info_read($mh));
    

    That appears to give the correct errno (specifically, the "result" => 6):

    Array
    (
        [httpcode] => 0
        [url] => http://404.php.net/
        [error] => Couldn't resolve host '404.php.net'
        [errorno] => 0
    )
    
    array(3) {
      ["msg"]=>
      int(1)
      ["result"]=>
      int(6)
      ["handle"]=>
      resource(7) of type (curl)
    }
    

    Note: tested out on a PHP 5.2.8 installation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I must write array of struct Data to hard disk: struct Data { char
I have data represented in CF as an array of structs e.g.: var foo
After puting the values in data base in an array and sending the values
The problem is like this: I have an array of 500 pointers which point
I have got an array of the following structs: typedef struct _my_data_ { unsigned
I am reading in data to a struct array. the data is separated by
I am trying to import data from a saved MATLAB struct array, but it
I am trying to copy a struct array to device.I am working with one
Consider the following code: struct TrainingExample { array<double, N> input; array<double, M> output; };
i am experiencing much trouble reading in files from input into an array struct.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.