3v4l.org

run code in 300+ PHP versions simultaneously
<?php $battery = "280"; $voltage_full = 320; // old hardware 100; $voltage_empty = 240; // old hardware 75; $voltage_range = $voltage_full - $voltage_empty; $batteryint = (int) $battery; $battery_range = $batteryint - $voltage_empty; if ( $battery >= $voltage_full ){ $battery_percentage = 100; } else { if ( $battery <= 240 ) { $battery_percentage = 0; } else { $battery_percentage = (100 * ($battery_range / $voltage_range)); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BU0Ho
function name:  (null)
number of ops:  21
compiled vars:  !0 = $battery, !1 = $voltage_full, !2 = $voltage_empty, !3 = $voltage_range, !4 = $batteryint, !5 = $battery_range, !6 = $battery_percentage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '280'
    4     1        ASSIGN                                                   !1, 320
    5     2        ASSIGN                                                   !2, 240
    6     3        SUB                                              ~10     !1, !2
          4        ASSIGN                                                   !3, ~10
    7     5        CAST                                          4  ~12     !0
          6        ASSIGN                                                   !4, ~12
    8     7        SUB                                              ~14     !4, !2
          8        ASSIGN                                                   !5, ~14
   10     9        IS_SMALLER_OR_EQUAL                                      !1, !0
         10      > JMPZ                                                     ~16, ->13
   11    11    >   ASSIGN                                                   !6, 100
         12      > JMP                                                      ->20
   14    13    >   IS_SMALLER_OR_EQUAL                                      !0, 240
         14      > JMPZ                                                     ~18, ->17
   15    15    >   ASSIGN                                                   !6, 0
         16      > JMP                                                      ->20
   18    17    >   DIV                                              ~20     !5, !3
         18        MUL                                              ~21     ~20, 100
         19        ASSIGN                                                   !6, ~21
   20    20    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.21 ms | 1394 KiB | 13 Q