3v4l.org

run code in 300+ PHP versions simultaneously
<?php //複数URLのコンテンツ、及び通信ステータスを一括取得する。 //サンプル: $urls = array( "https://i-bitzedge.com/cron/test/test_old.txt", "https://i-bitzedge.com/cron/test/test_new.txt", ); $results = getMultiContents($urls); echo $results[0]; function getMultiContents( $url_list ) { // マルチハンドルの用意 $mh = curl_multi_init(); // URLをキーとして、複数のCurlハンドルを入れて保持する配列 $ch_list = array(); // Curlハンドルの用意と、マルチハンドルへの登録 foreach( $url_list as $url ) { $ch_list[$url] = curl_init($url); curl_setopt($ch_list[$url], CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch_list[$url], CURLOPT_TIMEOUT, 1); // タイムアウト秒数を指定 curl_multi_add_handle($mh, $ch_list[$url]); } // 一括で通信実行、全て終わるのを待つ $running = null; do { curl_multi_exec($mh, $running); } while ( $running ); // 実行結果の取得 foreach( $url_list as $url ) { // ステータスとコンテンツ内容の取得 $results[$url] = curl_getinfo($ch_list[$url]); $results[$url]["content"] = curl_multi_getcontent($ch_list[$url]); // Curlハンドルの後始末 curl_multi_remove_handle($mh, $ch_list[$url]); curl_close($ch_list[$url]); } // マルチハンドルの後始末 curl_multi_close($mh); // 結果返却 return $results; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5EZrp
function name:  (null)
number of ops:  8
compiled vars:  !0 = $urls, !1 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
   10     1        INIT_FCALL_BY_NAME                                       'getMultiContents'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   11     5        FETCH_DIM_R                                      ~5      !1, 0
          6        ECHO                                                     ~5
   48     7      > RETURN                                                   1

Function getmulticontents:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 35
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 35
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 37
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 71
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 71
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 37
Branch analysis from position: 35
filename:       /in/5EZrp
function name:  getMultiContents
number of ops:  77
compiled vars:  !0 = $url_list, !1 = $mh, !2 = $ch_list, !3 = $url, !4 = $running, !5 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL_BY_NAME                                       'curl_multi_init'
          2        DO_FCALL                                      0  $6      
          3        ASSIGN                                                   !1, $6
   18     4        ASSIGN                                                   !2, <array>
   21     5      > FE_RESET_R                                       $9      !0, ->35
          6    > > FE_FETCH_R                                               $9, !3, ->35
   22     7    >   INIT_FCALL_BY_NAME                                       'curl_init'
          8        SEND_VAR_EX                                              !3
          9        DO_FCALL                                      0  $11     
         10        ASSIGN_DIM                                               !2, !3
         11        OP_DATA                                                  $11
   23    12        INIT_FCALL_BY_NAME                                       'curl_setopt'
         13        CHECK_FUNC_ARG                                           
         14        FETCH_DIM_FUNC_ARG                               $12     !2, !3
         15        SEND_FUNC_ARG                                            $12
         16        FETCH_CONSTANT                                   ~13     'CURLOPT_RETURNTRANSFER'
         17        SEND_VAL_EX                                              ~13
         18        SEND_VAL_EX                                              <true>
         19        DO_FCALL                                      0          
   24    20        INIT_FCALL_BY_NAME                                       'curl_setopt'
         21        CHECK_FUNC_ARG                                           
         22        FETCH_DIM_FUNC_ARG                               $15     !2, !3
         23        SEND_FUNC_ARG                                            $15
         24        FETCH_CONSTANT                                   ~16     'CURLOPT_TIMEOUT'
         25        SEND_VAL_EX                                              ~16
         26        SEND_VAL_EX                                              1
         27        DO_FCALL                                      0          
   25    28        INIT_FCALL_BY_NAME                                       'curl_multi_add_handle'
         29        SEND_VAR_EX                                              !1
         30        CHECK_FUNC_ARG                                           
         31        FETCH_DIM_FUNC_ARG                               $18     !2, !3
         32        SEND_FUNC_ARG                                            $18
         33        DO_FCALL                                      0          
   21    34      > JMP                                                      ->6
         35    >   FE_FREE                                                  $9
   29    36        ASSIGN                                                   !4, null
   30    37    >   INIT_FCALL_BY_NAME                                       'curl_multi_exec'
         38        SEND_VAR_EX                                              !1
         39        SEND_VAR_EX                                              !4
         40        DO_FCALL                                      0          
         41      > JMPNZ                                                    !4, ->37
   33    42    > > FE_RESET_R                                       $22     !0, ->71
         43    > > FE_FETCH_R                                               $22, !3, ->71
   35    44    >   INIT_FCALL_BY_NAME                                       'curl_getinfo'
         45        CHECK_FUNC_ARG                                           
         46        FETCH_DIM_FUNC_ARG                               $24     !2, !3
         47        SEND_FUNC_ARG                                            $24
         48        DO_FCALL                                      0  $25     
         49        ASSIGN_DIM                                               !5, !3
         50        OP_DATA                                                  $25
   36    51        INIT_FCALL_BY_NAME                                       'curl_multi_getcontent'
         52        CHECK_FUNC_ARG                                           
         53        FETCH_DIM_FUNC_ARG                               $28     !2, !3
         54        SEND_FUNC_ARG                                            $28
         55        DO_FCALL                                      0  $29     
         56        FETCH_DIM_W                                      $26     !5, !3
         57        ASSIGN_DIM                                               $26, 'content'
         58        OP_DATA                                                  $29
   39    59        INIT_FCALL_BY_NAME                                       'curl_multi_remove_handle'
         60        SEND_VAR_EX                                              !1
         61        CHECK_FUNC_ARG                                           
         62        FETCH_DIM_FUNC_ARG                               $30     !2, !3
         63        SEND_FUNC_ARG                                            $30
         64        DO_FCALL                                      0          
   40    65        INIT_FCALL_BY_NAME                                       'curl_close'
         66        CHECK_FUNC_ARG                                           
         67        FETCH_DIM_FUNC_ARG                               $32     !2, !3
         68        SEND_FUNC_ARG                                            $32
         69        DO_FCALL                                      0          
   33    70      > JMP                                                      ->43
         71    >   FE_FREE                                                  $22
   44    72        INIT_FCALL_BY_NAME                                       'curl_multi_close'
         73        SEND_VAR_EX                                              !1
         74        DO_FCALL                                      0          
   47    75      > RETURN                                                   !5
   48    76*     > RETURN                                                   null

End of function getmulticontents

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.43 ms | 1403 KiB | 13 Q