3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('KM', 6364.963); define('MILES', 3955.00465); function GetDistance($la1, $lo1, $la2, $lo2, $r = KM) { $l1 = deg2rad($la1); $l2 = deg2rad($la2); $dg = deg2rad($lo2 - $lo1); $d = $r * acos(sin($l1) * sin($l2) + cos($l1) * cos($l2) * cos($dg)); return $d; } $lat1 = 55; $long1 = 12; $lat2 = 34; $long2 = -118; echo "The distance from Copenhagen to Los Angeles is " . round(GetDistance($lat1, $long1, $lat2, $long2)) . " km\n"; echo "The distance from Copenhagen to Los Angeles is " . round(GetDistance($lat1, $long1, $lat2, $long2, MILES)) . " miles\n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M7hZe
function name:  (null)
number of ops:  39
compiled vars:  !0 = $lat1, !1 = $long1, !2 = $lat2, !3 = $long2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'KM'
          2        SEND_VAL                                                 6364.96
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'MILES'
          6        SEND_VAL                                                 3955
          7        DO_ICALL                                                 
   14     8        ASSIGN                                                   !0, 55
   15     9        ASSIGN                                                   !1, 12
   17    10        ASSIGN                                                   !2, 34
   18    11        ASSIGN                                                   !3, -118
   20    12        INIT_FCALL                                               'round'
         13        INIT_FCALL                                               'getdistance'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !3
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                         $11     
         21        CONCAT                                           ~12     'The+distance+from+Copenhagen+to+Los+Angeles+is+', $11
         22        CONCAT                                           ~13     ~12, '+km%0A'
         23        ECHO                                                     ~13
   21    24        INIT_FCALL                                               'round'
         25        INIT_FCALL                                               'getdistance'
         26        SEND_VAR                                                 !0
         27        SEND_VAR                                                 !1
         28        SEND_VAR                                                 !2
         29        SEND_VAR                                                 !3
         30        FETCH_CONSTANT                                   ~14     'MILES'
         31        SEND_VAL                                                 ~14
         32        DO_FCALL                                      0  $15     
         33        SEND_VAR                                                 $15
         34        DO_ICALL                                         $16     
         35        CONCAT                                           ~17     'The+distance+from+Copenhagen+to+Los+Angeles+is+', $16
         36        CONCAT                                           ~18     ~17, '+miles%0A'
         37        ECHO                                                     ~18
   22    38      > RETURN                                                   1

Function getdistance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M7hZe
function name:  GetDistance
number of ops:  44
compiled vars:  !0 = $la1, !1 = $lo1, !2 = $la2, !3 = $lo2, !4 = $r, !5 = $l1, !6 = $l2, !7 = $dg, !8 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV_INIT                                        !4      <const ast>
    7     5        INIT_FCALL                                               'deg2rad'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !5, $9
    8     9        INIT_FCALL                                               'deg2rad'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !6, $11
    9    13        INIT_FCALL                                               'deg2rad'
         14        SUB                                              ~13     !3, !1
         15        SEND_VAL                                                 ~13
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !7, $14
   10    18        INIT_FCALL                                               'acos'
         19        INIT_FCALL                                               'sin'
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                         $16     
         22        INIT_FCALL                                               'sin'
         23        SEND_VAR                                                 !6
         24        DO_ICALL                                         $17     
         25        MUL                                              ~18     $16, $17
         26        INIT_FCALL                                               'cos'
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                         $19     
         29        INIT_FCALL                                               'cos'
         30        SEND_VAR                                                 !6
         31        DO_ICALL                                         $20     
         32        MUL                                              ~21     $19, $20
         33        INIT_FCALL                                               'cos'
         34        SEND_VAR                                                 !7
         35        DO_ICALL                                         $22     
         36        MUL                                              ~23     $22, ~21
         37        ADD                                              ~24     ~18, ~23
         38        SEND_VAL                                                 ~24
         39        DO_ICALL                                         $25     
         40        MUL                                              ~26     !4, $25
         41        ASSIGN                                                   !8, ~26
   11    42      > RETURN                                                   !8
   12    43*     > RETURN                                                   null

End of function getdistance

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.17 ms | 1403 KiB | 27 Q