3v4l.org

run code in 300+ PHP versions simultaneously
<?php function distancia($lat1, $lon1, $lat2, $lon2, $unit) { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 1.1515; $unit = strtoupper($unit); if ($unit == "K") { return ($miles * 1.609344); } else if ($unit == "N") { return ($miles * 0.8684); } else { return $miles; } } // -12.971683, -38.460108 = bairro pernambues em salvador // -12.981290, -38.465043 = shopping iguatemi em salvador echo distancia(-12.971683, -38.460108, -12.981290, -38.981290, "k") . " Km<br />";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HtgAI
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'distancia'
          1        SEND_VAL                                                 -12.9717
          2        SEND_VAL                                                 -38.4601
          3        SEND_VAL                                                 -12.9813
          4        SEND_VAL                                                 -38.9813
          5        SEND_VAL                                                 'k'
          6        DO_FCALL                                      0  $0      
          7        CONCAT                                           ~1      $0, '+Km%3Cbr+%2F%3E'
          8        ECHO                                                     ~1
          9      > RETURN                                                   1

Function distancia:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 61
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 66
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HtgAI
function name:  distancia
number of ops:  68
compiled vars:  !0 = $lat1, !1 = $lon1, !2 = $lat2, !3 = $lon2, !4 = $unit, !5 = $theta, !6 = $dist, !7 = $miles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
    4     5        SUB                                              ~8      !1, !3
          6        ASSIGN                                                   !5, ~8
    5     7        INIT_FCALL                                               'sin'
          8        INIT_FCALL                                               'deg2rad'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $10     
         11        SEND_VAR                                                 $10
         12        DO_ICALL                                         $11     
         13        INIT_FCALL                                               'sin'
         14        INIT_FCALL                                               'deg2rad'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $12     
         17        SEND_VAR                                                 $12
         18        DO_ICALL                                         $13     
         19        MUL                                              ~14     $11, $13
         20        INIT_FCALL                                               'cos'
         21        INIT_FCALL                                               'deg2rad'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $15     
         24        SEND_VAR                                                 $15
         25        DO_ICALL                                         $16     
         26        INIT_FCALL                                               'cos'
         27        INIT_FCALL                                               'deg2rad'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $17     
         30        SEND_VAR                                                 $17
         31        DO_ICALL                                         $18     
         32        MUL                                              ~19     $16, $18
         33        INIT_FCALL                                               'cos'
         34        INIT_FCALL                                               'deg2rad'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                         $20     
         37        SEND_VAR                                                 $20
         38        DO_ICALL                                         $21     
         39        MUL                                              ~22     $21, ~19
         40        ADD                                              ~23     ~14, ~22
         41        ASSIGN                                                   !6, ~23
    6    42        INIT_FCALL                                               'acos'
         43        SEND_VAR                                                 !6
         44        DO_ICALL                                         $25     
         45        ASSIGN                                                   !6, $25
    7    46        INIT_FCALL                                               'rad2deg'
         47        SEND_VAR                                                 !6
         48        DO_ICALL                                         $27     
         49        ASSIGN                                                   !6, $27
    8    50        MUL                                              ~29     !6, 1.1515
         51        ASSIGN                                                   !7, ~29
    9    52        INIT_FCALL                                               'strtoupper'
         53        SEND_VAR                                                 !4
         54        DO_ICALL                                         $31     
         55        ASSIGN                                                   !4, $31
   11    56        IS_EQUAL                                                 !4, 'K'
         57      > JMPZ                                                     ~33, ->61
   12    58    >   MUL                                              ~34     !7, 1.60934
         59      > RETURN                                                   ~34
         60*       JMP                                                      ->67
   13    61    >   IS_EQUAL                                                 !4, 'N'
         62      > JMPZ                                                     ~35, ->66
   14    63    >   MUL                                              ~36     !7, 0.8684
         64      > RETURN                                                   ~36
         65*       JMP                                                      ->67
   16    66    > > RETURN                                                   !7
   18    67*     > RETURN                                                   null

End of function distancia

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.76 ms | 1394 KiB | 26 Q