1--TEST-- 2Test curl_setopt() with curl_multi function with basic functionality 3--CREDITS-- 4TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> 5--EXTENSIONS-- 6curl 7--FILE-- 8<?php 9 include 'server.inc'; 10 $host = curl_cli_server_start(); 11 12 // start testing 13 echo "*** Testing curl_exec() : basic functionality ***\n"; 14 15 $url = "{$host}/get.inc?test=get"; 16 $chs = array( 17 0 => curl_init(), 18 1 => curl_init(), 19 2 => curl_init(), 20 ); 21 22 ob_start(); // start output buffering 23 24 $options = array( 25 CURLOPT_RETURNTRANSFER => 1, 26 CURLOPT_URL => $url, 27 ); 28 29 curl_setopt_array($chs[0], $options); //set the options 30 curl_setopt_array($chs[1], $options); //set the options 31 curl_setopt_array($chs[2], $options); //set the options 32 33 $mh = curl_multi_init(); 34 35 // add handlers 36 curl_multi_add_handle($mh, $chs[0]); 37 curl_multi_add_handle($mh, $chs[1]); 38 curl_multi_add_handle($mh, $chs[2]); 39 40 $running=null; 41 //execute the handles 42 do { 43 curl_multi_exec($mh, $running); 44 } while ($running > 0); 45 46 $curl_content = ''; 47 $curl_content .= curl_multi_getcontent($chs[0]); 48 $curl_content .= curl_multi_getcontent($chs[1]); 49 $curl_content .= curl_multi_getcontent($chs[2]); 50 51 //close the handles 52 curl_multi_remove_handle($mh, $chs[0]); 53 curl_multi_remove_handle($mh, $chs[1]); 54 curl_multi_remove_handle($mh, $chs[2]); 55 curl_multi_close($mh); 56 57 var_dump( $curl_content ); 58 59?> 60--EXPECT-- 61*** Testing curl_exec() : basic functionality *** 62string(75) "Hello World! 63Hello World!Hello World! 64Hello World!Hello World! 65Hello World!" 66