3v4l.org

run code in 300+ PHP versions simultaneously
<?php function distanceGeoPoints ($lat1, $lng1, $lat2, $lng2) { $earthRadius = 3958.75; $dLat = deg2rad($lat2-$lat1); $dLng = deg2rad($lng2-$lng1); $a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($dLng/2) * sin($dLng/2); $c = 2 * atan2(sqrt($a), sqrt(1-$a)); $dist = $earthRadius * $c; // from miles $meterConversion = 1609; $geopointDistance = $dist * $meterConversion; // meters to km $geopointDistance = round($geopointDistance / 1000); return $geopointDistance; } // input here echo distanceGeoPoints(53.2168710816799, 6.5573533796185, 53.1402726806595, 6.5633787486733). ' km'; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wmop5
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'distancegeopoints'
          1        SEND_VAL                                                 53.2169
          2        SEND_VAL                                                 6.55735
          3        SEND_VAL                                                 53.1403
          4        SEND_VAL                                                 6.56338
          5        DO_FCALL                                      0  $0      
          6        CONCAT                                           ~1      $0, '+km'
          7        ECHO                                                     ~1
   31     8      > RETURN                                                   1

Function distancegeopoints:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wmop5
function name:  distanceGeoPoints
number of ops:  74
compiled vars:  !0 = $lat1, !1 = $lng1, !2 = $lat2, !3 = $lng2, !4 = $earthRadius, !5 = $dLat, !6 = $dLng, !7 = $a, !8 = $c, !9 = $dist, !10 = $meterConversion, !11 = $geopointDistance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    5     4        ASSIGN                                                   !4, 3958.75
    7     5        INIT_FCALL                                               'deg2rad'
          6        SUB                                              ~13     !2, !0
          7        SEND_VAL                                                 ~13
          8        DO_ICALL                                         $14     
          9        ASSIGN                                                   !5, $14
    8    10        INIT_FCALL                                               'deg2rad'
         11        SUB                                              ~16     !3, !1
         12        SEND_VAL                                                 ~16
         13        DO_ICALL                                         $17     
         14        ASSIGN                                                   !6, $17
   11    15        INIT_FCALL                                               'sin'
         16        DIV                                              ~19     !5, 2
         17        SEND_VAL                                                 ~19
         18        DO_ICALL                                         $20     
         19        INIT_FCALL                                               'sin'
         20        DIV                                              ~21     !5, 2
         21        SEND_VAL                                                 ~21
         22        DO_ICALL                                         $22     
         23        MUL                                              ~23     $20, $22
   12    24        INIT_FCALL                                               'cos'
         25        INIT_FCALL                                               'deg2rad'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $24     
         28        SEND_VAR                                                 $24
         29        DO_ICALL                                         $25     
         30        INIT_FCALL                                               'cos'
         31        INIT_FCALL                                               'deg2rad'
         32        SEND_VAR                                                 !2
         33        DO_ICALL                                         $26     
         34        SEND_VAR                                                 $26
         35        DO_ICALL                                         $27     
         36        MUL                                              ~28     $25, $27
   13    37        INIT_FCALL                                               'sin'
         38        DIV                                              ~29     !6, 2
         39        SEND_VAL                                                 ~29
         40        DO_ICALL                                         $30     
         41        MUL                                              ~31     $30, ~28
         42        INIT_FCALL                                               'sin'
         43        DIV                                              ~32     !6, 2
         44        SEND_VAL                                                 ~32
         45        DO_ICALL                                         $33     
         46        MUL                                              ~34     $33, ~31
         47        ADD                                              ~35     ~23, ~34
   11    48        ASSIGN                                                   !7, ~35
   14    49        INIT_FCALL                                               'atan2'
         50        INIT_FCALL                                               'sqrt'
         51        SEND_VAR                                                 !7
         52        DO_ICALL                                         $37     
         53        SEND_VAR                                                 $37
         54        INIT_FCALL                                               'sqrt'
         55        SUB                                              ~38     1, !7
         56        SEND_VAL                                                 ~38
         57        DO_ICALL                                         $39     
         58        SEND_VAR                                                 $39
         59        DO_ICALL                                         $40     
         60        MUL                                              ~41     $40, 2
         61        ASSIGN                                                   !8, ~41
   15    62        MUL                                              ~43     !4, !8
         63        ASSIGN                                                   !9, ~43
   18    64        ASSIGN                                                   !10, 1609
   19    65        MUL                                              ~46     !9, !10
         66        ASSIGN                                                   !11, ~46
   22    67        INIT_FCALL                                               'round'
         68        DIV                                              ~48     !11, 1000
         69        SEND_VAL                                                 ~48
         70        DO_ICALL                                         $49     
         71        ASSIGN                                                   !11, $49
   25    72      > RETURN                                                   !11
   26    73*     > RETURN                                                   null

End of function distancegeopoints

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.34 ms | 1403 KiB | 26 Q