1--TEST-- 2Curl_multi_getcontent() basic test with different sources (local file/http) 3--CREDITS-- 4Rein Velt (rein@velt.org) 5#TestFest Utrecht 20090509 6--EXTENSIONS-- 7curl 8--SKIPIF-- 9<?php 10if (curl_version()['version_number'] === 0x080a00) { 11 // https://github.com/php/php-src/issues/15997 12 die('xfail due to a libcurl bug'); 13} 14?> 15--FILE-- 16<?php 17 //CURL_MULTI_GETCONTENT TEST 18 19 //CREATE RESOURCES 20 $ch1=curl_init(); 21 $ch2=curl_init(); 22 23 //SET URL AND OTHER OPTIONS 24 include 'server.inc'; 25 $host = curl_cli_server_start(); 26 curl_setopt($ch1, CURLOPT_URL, "{$host}/get.inc?test=getpost&get_param=Hello%20World"); 27 curl_setopt($ch2, CURLOPT_URL, "file://".__DIR__. DIRECTORY_SEPARATOR . "curl_testdata2.txt"); 28 curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); 29 curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); 30 31 //CREATE MULTIPLE CURL HANDLE 32 $mh=curl_multi_init(); 33 34 //ADD THE 2 HANDLES 35 curl_multi_add_handle($mh,$ch1); 36 curl_multi_add_handle($mh,$ch2); 37 38 //EXECUTE 39 $running=0; 40 do { 41 curl_multi_exec($mh,$running); 42 } while ($running>0); 43 44 $results1=curl_multi_getcontent($ch1); 45 $results2=curl_multi_getcontent($ch2); 46 47 //CLOSE 48 curl_multi_remove_handle($mh,$ch1); 49 curl_multi_remove_handle($mh,$ch2); 50 curl_multi_close($mh); 51 52 echo $results1; 53 echo $results2; 54 55?> 56--EXPECT-- 57array(2) { 58 ["test"]=> 59 string(7) "getpost" 60 ["get_param"]=> 61 string(11) "Hello World" 62} 63array(0) { 64} 65CURL2 66