3v4l.org

run code in 300+ PHP versions simultaneously
<?php function CallAPI($method, $url, $data = false) { $curl = curl_init(); switch ($method) { case "POST": curl_setopt($curl, CURLOPT_POST, 1); if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data); break; case "PUT": curl_setopt($curl, CURLOPT_PUT, 1); break; default: if ($data) $url = sprintf("%s?%s", $url, http_build_query($data)); } // Optional Authentication: curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "username:password"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); return curl_exec($curl); } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p40B9
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E > > RETURN                                                   1

Function callapi:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 12, Position 2 = 26, Position 3 = 33, Position 4 = 7
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 43
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 26
Branch analysis from position: 12
filename:       /in/p40B9
function name:  CallAPI
number of ops:  73
compiled vars:  !0 = $method, !1 = $url, !2 = $data, !3 = $curl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
    4     3        INIT_FCALL_BY_NAME                                       'curl_init'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !3, $4
    6     6      > SWITCH_STRING                                            !0, [ 'POST':->12, 'PUT':->26, ], ->33
    8     7    >   IS_EQUAL                                                 !0, 'POST'
          8      > JMPNZ                                                    ~6, ->12
   14     9    >   IS_EQUAL                                                 !0, 'PUT'
         10      > JMPNZ                                                    ~6, ->26
         11    > > JMP                                                      ->33
    9    12    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         13        SEND_VAR_EX                                              !3
         14        FETCH_CONSTANT                                   ~7      'CURLOPT_POST'
         15        SEND_VAL_EX                                              ~7
         16        SEND_VAL_EX                                              1
         17        DO_FCALL                                      0          
   11    18      > JMPZ                                                     !2, ->25
   12    19    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         20        SEND_VAR_EX                                              !3
         21        FETCH_CONSTANT                                   ~9      'CURLOPT_POSTFIELDS'
         22        SEND_VAL_EX                                              ~9
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0          
   13    25    > > JMP                                                      ->43
   15    26    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         27        SEND_VAR_EX                                              !3
         28        FETCH_CONSTANT                                   ~11     'CURLOPT_PUT'
         29        SEND_VAL_EX                                              ~11
         30        SEND_VAL_EX                                              1
         31        DO_FCALL                                      0          
   16    32      > JMP                                                      ->43
   18    33    > > JMPZ                                                     !2, ->43
   19    34    >   INIT_FCALL                                               'sprintf'
         35        SEND_VAL                                                 '%25s%3F%25s'
         36        SEND_VAR                                                 !1
         37        INIT_FCALL                                               'http_build_query'
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                         $13     
         40        SEND_VAR                                                 $13
         41        DO_ICALL                                         $14     
         42        ASSIGN                                                   !1, $14
   23    43    >   INIT_FCALL_BY_NAME                                       'curl_setopt'
         44        SEND_VAR_EX                                              !3
         45        FETCH_CONSTANT                                   ~16     'CURLOPT_HTTPAUTH'
         46        SEND_VAL_EX                                              ~16
         47        FETCH_CONSTANT                                   ~17     'CURLAUTH_BASIC'
         48        SEND_VAL_EX                                              ~17
         49        DO_FCALL                                      0          
   24    50        INIT_FCALL_BY_NAME                                       'curl_setopt'
         51        SEND_VAR_EX                                              !3
         52        FETCH_CONSTANT                                   ~19     'CURLOPT_USERPWD'
         53        SEND_VAL_EX                                              ~19
         54        SEND_VAL_EX                                              'username%3Apassword'
         55        DO_FCALL                                      0          
   26    56        INIT_FCALL_BY_NAME                                       'curl_setopt'
         57        SEND_VAR_EX                                              !3
         58        FETCH_CONSTANT                                   ~21     'CURLOPT_URL'
         59        SEND_VAL_EX                                              ~21
         60        SEND_VAR_EX                                              !1
         61        DO_FCALL                                      0          
   27    62        INIT_FCALL_BY_NAME                                       'curl_setopt'
         63        SEND_VAR_EX                                              !3
         64        FETCH_CONSTANT                                   ~23     'CURLOPT_RETURNTRANSFER'
         65        SEND_VAL_EX                                              ~23
         66        SEND_VAL_EX                                              1
         67        DO_FCALL                                      0          
   29    68        INIT_FCALL_BY_NAME                                       'curl_exec'
         69        SEND_VAR_EX                                              !3
         70        DO_FCALL                                      0  $25     
         71      > RETURN                                                   $25
   30    72*     > RETURN                                                   null

End of function callapi

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.07 ms | 1400 KiB | 17 Q