3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_currency($from_Currency, $to_Currency, $amount) { $amount = urlencode($amount); $from_Currency = urlencode($from_Currency); $to_Currency = urlencode($to_Currency); $url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency"; $ch = curl_init(); $timeout = 0; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $rawdata = curl_exec($ch); curl_close($ch); $data = explode('bld>', $rawdata); $data = explode($to_Currency, $data[1]); return round($data[0], 2); } // Call the function to get the currency converted echo get_currency('USD', 'NZD', 1); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dHJpU
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'get_currency'
          1        SEND_VAL                                                 'USD'
          2        SEND_VAL                                                 'NZD'
          3        SEND_VAL                                                 1
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
   29     6      > RETURN                                                   1

Function get_currency:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dHJpU
function name:  get_currency
number of ops:  75
compiled vars:  !0 = $from_Currency, !1 = $to_Currency, !2 = $amount, !3 = $url, !4 = $ch, !5 = $timeout, !6 = $rawdata, !7 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'urlencode'
          4        SEND_VAR                                                 !2
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
    5     7        INIT_FCALL                                               'urlencode'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $10     
         10        ASSIGN                                                   !0, $10
    6    11        INIT_FCALL                                               'urlencode'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !1, $12
    8    15        ROPE_INIT                                     6  ~15     'http%3A%2F%2Fwww.google.com%2Ffinance%2Fconverter%3Fa%3D'
         16        ROPE_ADD                                      1  ~15     ~15, !2
         17        ROPE_ADD                                      2  ~15     ~15, '%26from%3D'
         18        ROPE_ADD                                      3  ~15     ~15, !0
         19        ROPE_ADD                                      4  ~15     ~15, '%26to%3D'
         20        ROPE_END                                      5  ~14     ~15, !1
         21        ASSIGN                                                   !3, ~14
   10    22        INIT_FCALL_BY_NAME                                       'curl_init'
         23        DO_FCALL                                      0  $19     
         24        ASSIGN                                                   !4, $19
   11    25        ASSIGN                                                   !5, 0
   12    26        INIT_FCALL_BY_NAME                                       'curl_setopt'
         27        SEND_VAR_EX                                              !4
         28        FETCH_CONSTANT                                   ~22     'CURLOPT_URL'
         29        SEND_VAL_EX                                              ~22
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0          
   13    32        INIT_FCALL_BY_NAME                                       'curl_setopt'
         33        SEND_VAR_EX                                              !4
         34        FETCH_CONSTANT                                   ~24     'CURLOPT_RETURNTRANSFER'
         35        SEND_VAL_EX                                              ~24
         36        SEND_VAL_EX                                              1
         37        DO_FCALL                                      0          
   15    38        INIT_FCALL_BY_NAME                                       'curl_setopt'
         39        SEND_VAR_EX                                              !4
         40        FETCH_CONSTANT                                   ~26     'CURLOPT_USERAGENT'
         41        SEND_VAL_EX                                              ~26
   16    42        SEND_VAL_EX                                              'Mozilla%2F4.0+%28compatible%3B+MSIE+8.0%3B+Windows+NT+6.1%29'
         43        DO_FCALL                                      0          
   17    44        INIT_FCALL_BY_NAME                                       'curl_setopt'
         45        SEND_VAR_EX                                              !4
         46        FETCH_CONSTANT                                   ~28     'CURLOPT_CONNECTTIMEOUT'
         47        SEND_VAL_EX                                              ~28
         48        SEND_VAR_EX                                              !5
         49        DO_FCALL                                      0          
   18    50        INIT_FCALL_BY_NAME                                       'curl_exec'
         51        SEND_VAR_EX                                              !4
         52        DO_FCALL                                      0  $30     
         53        ASSIGN                                                   !6, $30
   19    54        INIT_FCALL_BY_NAME                                       'curl_close'
         55        SEND_VAR_EX                                              !4
         56        DO_FCALL                                      0          
   20    57        INIT_FCALL                                               'explode'
         58        SEND_VAL                                                 'bld%3E'
         59        SEND_VAR                                                 !6
         60        DO_ICALL                                         $33     
         61        ASSIGN                                                   !7, $33
   21    62        INIT_FCALL                                               'explode'
         63        SEND_VAR                                                 !1
         64        FETCH_DIM_R                                      ~35     !7, 1
         65        SEND_VAL                                                 ~35
         66        DO_ICALL                                         $36     
         67        ASSIGN                                                   !7, $36
   23    68        INIT_FCALL                                               'round'
         69        FETCH_DIM_R                                      ~38     !7, 0
         70        SEND_VAL                                                 ~38
         71        SEND_VAL                                                 2
         72        DO_ICALL                                         $39     
         73      > RETURN                                                   $39
   24    74*     > RETURN                                                   null

End of function get_currency

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.75 ms | 1403 KiB | 20 Q