3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_url_contents($url){ $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } function post_url_contents($url, $fields) { foreach($fields as $key=>$value) { $fields_string .= $key.'='.urlencode($value).'&'; } rtrim($fields_string, '&'); $crl = curl_init(); $timeout = 5; curl_setopt($crl, CURLOPT_URL,$url); curl_setopt($crl,CURLOPT_POST, count($fields)); curl_setopt($crl,CURLOPT_POSTFIELDS, $fields_string); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } $streams = json_decode(get_url_contents("https://api.twitch.tv/kraken/streams")); echo "name" . $streams->streams[0]->channel->name;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X2CNW
function name:  (null)
number of ops:  14
compiled vars:  !0 = $streams
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'json_decode'
          1        INIT_FCALL                                               'get_url_contents'
          2        SEND_VAL                                                 'https%3A%2F%2Fapi.twitch.tv%2Fkraken%2Fstreams'
          3        DO_FCALL                                      0  $1      
          4        SEND_VAR                                                 $1
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   34     7        FETCH_OBJ_R                                      ~4      !0, 'streams'
          8        FETCH_DIM_R                                      ~5      ~4, 0
          9        FETCH_OBJ_R                                      ~6      ~5, 'channel'
         10        FETCH_OBJ_R                                      ~7      ~6, 'name'
         11        CONCAT                                           ~8      'name', ~7
         12        ECHO                                                     ~8
         13      > RETURN                                                   1

Function get_url_contents:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X2CNW
function name:  get_url_contents
number of ops:  32
compiled vars:  !0 = $url, !1 = $crl, !2 = $timeout, !3 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL_BY_NAME                                       'curl_init'
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                                   !1, $4
    5     4        ASSIGN                                                   !2, 5
    6     5        INIT_FCALL_BY_NAME                                       'curl_setopt'
          6        SEND_VAR_EX                                              !1
          7        FETCH_CONSTANT                                   ~7      'CURLOPT_URL'
          8        SEND_VAL_EX                                              ~7
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
    7    11        INIT_FCALL_BY_NAME                                       'curl_setopt'
         12        SEND_VAR_EX                                              !1
         13        FETCH_CONSTANT                                   ~9      'CURLOPT_RETURNTRANSFER'
         14        SEND_VAL_EX                                              ~9
         15        SEND_VAL_EX                                              1
         16        DO_FCALL                                      0          
    8    17        INIT_FCALL_BY_NAME                                       'curl_setopt'
         18        SEND_VAR_EX                                              !1
         19        FETCH_CONSTANT                                   ~11     'CURLOPT_CONNECTTIMEOUT'
         20        SEND_VAL_EX                                              ~11
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0          
    9    23        INIT_FCALL_BY_NAME                                       'curl_exec'
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0  $13     
         26        ASSIGN                                                   !3, $13
   10    27        INIT_FCALL_BY_NAME                                       'curl_close'
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0          
   11    30      > RETURN                                                   !3
   12    31*     > RETURN                                                   null

End of function get_url_contents

Function post_url_contents:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/X2CNW
function name:  post_url_contents
number of ops:  62
compiled vars:  !0 = $url, !1 = $fields, !2 = $value, !3 = $key, !4 = $fields_string, !5 = $crl, !6 = $timeout, !7 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2      > FE_RESET_R                                       $8      !1, ->13
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->13
          4    >   ASSIGN                                                   !3, ~9
          5        CONCAT                                           ~11     !3, '%3D'
          6        INIT_FCALL                                               'urlencode'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $12     
          9        CONCAT                                           ~13     ~11, $12
         10        CONCAT                                           ~14     ~13, '%26'
         11        ASSIGN_OP                                     8          !4, ~14
         12      > JMP                                                      ->3
         13    >   FE_FREE                                                  $8
   17    14        INIT_FCALL                                               'rtrim'
         15        SEND_VAR                                                 !4
         16        SEND_VAL                                                 '%26'
         17        DO_ICALL                                                 
   19    18        INIT_FCALL_BY_NAME                                       'curl_init'
         19        DO_FCALL                                      0  $17     
         20        ASSIGN                                                   !5, $17
   20    21        ASSIGN                                                   !6, 5
   22    22        INIT_FCALL_BY_NAME                                       'curl_setopt'
         23        SEND_VAR_EX                                              !5
         24        FETCH_CONSTANT                                   ~20     'CURLOPT_URL'
         25        SEND_VAL_EX                                              ~20
         26        SEND_VAR_EX                                              !0
         27        DO_FCALL                                      0          
   23    28        INIT_FCALL_BY_NAME                                       'curl_setopt'
         29        SEND_VAR_EX                                              !5
         30        FETCH_CONSTANT                                   ~22     'CURLOPT_POST'
         31        SEND_VAL_EX                                              ~22
         32        COUNT                                            ~23     !1
         33        SEND_VAL_EX                                              ~23
         34        DO_FCALL                                      0          
   24    35        INIT_FCALL_BY_NAME                                       'curl_setopt'
         36        SEND_VAR_EX                                              !5
         37        FETCH_CONSTANT                                   ~25     'CURLOPT_POSTFIELDS'
         38        SEND_VAL_EX                                              ~25
         39        SEND_VAR_EX                                              !4
         40        DO_FCALL                                      0          
   26    41        INIT_FCALL_BY_NAME                                       'curl_setopt'
         42        SEND_VAR_EX                                              !5
         43        FETCH_CONSTANT                                   ~27     'CURLOPT_RETURNTRANSFER'
         44        SEND_VAL_EX                                              ~27
         45        SEND_VAL_EX                                              1
         46        DO_FCALL                                      0          
   27    47        INIT_FCALL_BY_NAME                                       'curl_setopt'
         48        SEND_VAR_EX                                              !5
         49        FETCH_CONSTANT                                   ~29     'CURLOPT_CONNECTTIMEOUT'
         50        SEND_VAL_EX                                              ~29
         51        SEND_VAR_EX                                              !6
         52        DO_FCALL                                      0          
   28    53        INIT_FCALL_BY_NAME                                       'curl_exec'
         54        SEND_VAR_EX                                              !5
         55        DO_FCALL                                      0  $31     
         56        ASSIGN                                                   !7, $31
   29    57        INIT_FCALL_BY_NAME                                       'curl_close'
         58        SEND_VAR_EX                                              !5
         59        DO_FCALL                                      0          
   30    60      > RETURN                                                   !7
   31    61*     > RETURN                                                   null

End of function post_url_contents

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.45 ms | 1398 KiB | 20 Q