ID:              41598
 User updated by: andrew dot minerd at sellingsource dot com
 Reported By:     andrew dot minerd at sellingsource dot com
 Status:          Open
 Bug Type:        Documentation problem
 PHP Version:     Irrelevant
 New Comment:

Note that the same example is also used on the documentation pages
for:

* curl_multi_add_handle
* curl_multi_close
* curl_multi_init


Previous Comments:
------------------------------------------------------------------------

[2007-06-05 15:20:19] andrew dot minerd at sellingsource dot com

Patch for a working example:

--- ./test-curl-orig.php        2007-06-05 08:11:31.000000000 -0700
+++ ./test-curl.php     2007-06-05 08:11:05.000000000 -0700
@@ -4,22 +4,26 @@
 $ch2 = curl_init();
 
 // set URL and other appropriate options
-curl_setopt($ch, CURLOPT_URL, "http://www.example.com/";);
-curl_setopt($ch, CURLOPT_HEADER, 0);
-curl_setopt($ch, CURLOPT_URL, "http://www.php.net/";);
-curl_setopt($ch, CURLOPT_HEADER, 0);
+curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/";);
+curl_setopt($ch1, CURLOPT_HEADER, 0);
+curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/";);
+curl_setopt($ch2, CURLOPT_HEADER, 0);
 
 //create the multiple cURL handle
 $mh = curl_multi_init();
 
 //add the two handles
-curl_multi_add_handle($mh,$ch1);
-curl_multi_add_handle($mh,$ch2);
+curl_multi_add_handle($mh, $ch1);
+curl_multi_add_handle($mh, $ch2);
 
 //execute the handles
-curl_multi_exec($mh);
+do {
+       curl_multi_exec($mh, $running);
+} while ($running > 0);
 
 //close the handles
-curl_multi_close();
+curl_multi_remove_handle($ch1);
+curl_multi_remove_handle($ch2);
+curl_multi_close($mh);
 
 ?>

------------------------------------------------------------------------

[2007-06-05 15:18:18] andrew dot minerd at sellingsource dot com

Description:
------------
The documentation for curl_multi_exec includes a code example that
doesn't work: it uses undeclared curl handles ($ch rather than $ch1 or
$ch2), only calls curl_multi_exec once (which doesn't complete the
transfer), and doesn't have enough parameters for the curl_multi_exec
call.

Reproduce code:
---------------
See http://php.net/curl_multi_exec

Expected result:
----------------
The contents of http://www.example.com (if it existed) and
http://www.php.net will be downloaded and displayed.

Actual result:
--------------
Notice: Undefined variable: ch in /home/andrewm/test-curl-orig.php on
line 7

Warning: curl_setopt(): supplied argument is not a valid cURL handle
resource in /home/andrewm/test-curl-orig.php on line 7

Notice: Undefined variable: ch in /home/andrewm/test-curl-orig.php on
line 8

Warning: curl_setopt(): supplied argument is not a valid cURL handle
resource in /home/andrewm/test-curl-orig.php on line 8

Notice: Undefined variable: ch in /home/andrewm/test-curl-orig.php on
line 9

Warning: curl_setopt(): supplied argument is not a valid cURL handle
resource in /home/andrewm/test-curl-orig.php on line 9

Notice: Undefined variable: ch in /home/andrewm/test-curl-orig.php on
line 10

Warning: curl_setopt(): supplied argument is not a valid cURL handle
resource in /home/andrewm/test-curl-orig.php on line 10

Warning: curl_multi_exec() expects exactly 2 parameters, 1 given in
/home/andrewm/test-curl-orig.php on line 20

Warning: curl_multi_close() expects exactly 1 parameter, 0 given in
/home/andrewm/test-curl-orig.php on line 23



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41598&edit=1

Reply via email to