PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

curl_multi_remove_handle> <curl_multi_info_read
Last updated: Fri, 11 Apr 2008

view this page in

curl_multi_init

(PHP 5)

curl_multi_init — Returns a new cURL multi handle

Opis

resource curl_multi_init ( void )

Allows the processing of multiple cURL handles in parallel.

Parametry

mh

Wielokrotny uchwyt cURL zwrócony przez curl_multi_init().

Zwracane wartości

Returns a cURL on handle on success, FALSE on failure.

Przykłady

Example #1 curl_multi_init() example

This example will create two cURL handles, add them to a multi handle, and then run them in parallel.

<?php
// create both cURL resources
$ch1 curl_init();
$ch2 curl_init();

// set URL and other appropriate options
curl_setopt($ch1CURLOPT_URL"http://www.example.com/");
curl_setopt($ch1CURLOPT_HEADER0);
curl_setopt($ch2CURLOPT_URL"http://www.php.net/");
curl_setopt($ch2CURLOPT_HEADER0);

//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);

$running=null;
//execute the handles
do {
    
curl_multi_exec($mh,$running);
} while (
$running 0);

//close the handles
curl_multi_remove_handle($ch1);
curl_multi_remove_handle($ch2);
curl_multi_close($mh);

?>



curl_multi_remove_handle> <curl_multi_info_read
Last updated: Fri, 11 Apr 2008
 
add a note add a note User Contributed Notes
curl_multi_init
ssttoo at gmail dot com
26-Feb-2008 02:57
An example of how to make parallel POST/GET requests through a reusable function:
http://www.phpied.com/simultaneuos-http-requests-in-php-with-curl/
Anonymous
25-Jan-2008 07:09
In the example above, rather than busy looping, curl_multi_select() should be used.  The call isn't adequately described in the php documentation, so you need to look at the libcurl-multi man page.  curl_multi_fdset() on this page is  curl_multi_select() here, and curl_multi_perform() is curl_multi_exec() here.  Read on and write better code.
php at twobears dot cz
17-Dec-2007 07:02
It's not good to use plain while cycle like in the example because you are going to consume all the cpu time just by checking if you are not done. E.g. using usleep(50) in the middle of while could solve that gracefully...
snoyes at gmail dot com
30-Jul-2007 04:39
In the example shown, the calls to curl_multi_remove_handle() should include the resource as the first parameter:

curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);

curl_multi_remove_handle> <curl_multi_info_read
Last updated: Fri, 11 Apr 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites