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

search for in the

curl_multi_remove_handle> <curl_multi_info_read
[edit] Last updated: Fri, 23 Mar 2012

view this page in

curl_multi_init

(PHP 5)

curl_multi_initYeni bir çoklu cURL tanıtıcısı döndürür

Açıklama

resource curl_multi_init ( void )

Çok sayıda cURL tanıtıcısının aynı anda işlem görmesini sağlar.

Değiştirgeler

cct

curl_multi_init() işlevinden dönen çoklu cURL tanıtıcısı.

Dönen Değerler

Başarı durumunda bir çoklu-cURL tanıtıcısı yoksa FALSE döner.

Örnekler

Örnek 1 - curl_multi_init() örneği

Bu örnekte iki cURL tanıtıcısı oluşturulup bir çoklu tanıtıcıya eklenip bu ikisi birlikte çalıştırılmaktadır.

<?php
// iki cURL özkaynağı oluşturalım
$ct1 curl_init();
$ct2 curl_init();

// URL'yi ve ilgili seçenekleri belirtelim
curl_setopt($ct1CURLOPT_URL"http://www.example.com/");
curl_setopt($ct1CURLOPT_HEADER0);
curl_setopt($ct2CURLOPT_URL"http://www.php.net/");
curl_setopt($ct2CURLOPT_HEADER0);

// çoklu cURL tanıtıcısını oluşturalım
$cct curl_multi_init();

// iki tanıtıcıyı buna ekleyelim
curl_multi_add_handle($cct,$ct1);
curl_multi_add_handle($cct,$ct2);

$running=null;
// tanıtıcıları çalıştıralım
do {
    
curl_multi_exec($cct,$running);
} while (
$running 0);

// tanıtıcıları kapatalım
curl_multi_remove_handle($cct$ct1);
curl_multi_remove_handle($cct$ct2);
curl_multi_close($cct);

?>

Ayrıca Bakınız



add a note add a note User Contributed Notes curl_multi_init
hushuilong at gmail dot com 04-Aug-2011 06:21
Simulate multiple threads request:
<?php
function multiple_threads_request($nodes){
       
$mh = curl_multi_init();
       
$curl_array = array();
        foreach(
$nodes as $i => $url)
        {
           
$curl_array[$i] = curl_init($url);
           
curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, true);
           
curl_multi_add_handle($mh, $curl_array[$i]);
        }
       
$running = NULL;
        do {
           
usleep(10000);
           
curl_multi_exec($mh,$running);
        } while(
$running > 0);
       
       
$res = array();
        foreach(
$nodes as $i => $url)
        {
           
$res[$url] = curl_multi_getcontent($curl_array[$i]);
        }
       
        foreach(
$nodes as $i => $url){
           
curl_multi_remove_handle($mh, $curl_array[$i]);
        }
       
curl_multi_close($mh);       
        return
$res;
}
print_r(muti_thread_request(array(
   
'http://www.example.com',
   
'http://www.example.net',
)));
?>
jaisen at jmathai dot com 29-May-2008 06:09
http://github.com/jmathai/epicode/tree/master/php/EpiCurl.php

If you fire off 10 curl requests in parallel you don't have to wait for all of them to be finished before accessing one which is already finished.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites