3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // 並列通信用マルチハンドルを用意 $mh = curl_multi_init(); // 通信先ごとにCurl Handleを作り、それを $mh にaddしていく $ch_news = curl_init("http://dailynews.yahoo.co.jp/fc/entertainment/rss.xml"); curl_setopt($ch_news, CURLOPT_RETURNTRANSFER, TRUE); curl_multi_add_handle($mh, $ch_news); // 同様に $ch_music = curl_init("http://magazine.music.yahoo.co.jp/rss/ALL/rss.xml"); curl_setopt($ch_music, CURLOPT_RETURNTRANSFER, TRUE); curl_multi_add_handle($mh, $ch_music); // 同様に $ch_trend = curl_init("http://searchranking.yahoo.co.jp/rss/trend-rss.xml"); curl_setopt($ch_trend, CURLOPT_RETURNTRANSFER, TRUE); curl_multi_add_handle($mh, $ch_trend); // せーので複数の通信を同時実行。whileで全て返ってくるのを待ちます do { curl_multi_exec($mh, $running); } while ( $running ); // 個々のXMLは、それぞれのCurl Handleを指定することで取得できる $rss_news = curl_multi_getcontent($ch_news); $rss_music = curl_multi_getcontent($ch_music); $rss_trend = curl_multi_getcontent($ch_trend); // 後始末 curl_multi_remove_handle($mh, $ch_news); curl_close($ch_news); curl_multi_remove_handle($mh, $ch_music); curl_close($ch_music); curl_multi_remove_handle($mh, $ch_trend); curl_close($ch_trend); curl_multi_close($mh);
based on mHLl2
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function curl_multi_init() in /in/Jt3CJ:3 Stack trace: #0 {main} thrown in /in/Jt3CJ on line 3
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Call to undefined function curl_multi_init() in /in/Jt3CJ on line 3
Process exited with code 255.