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; $battery = (int) $battery; $battery_range = $battery - $voltage_empty; if ( $battery >= $voltage_full ){ $battery_percentage = 100; } else { if ( $battery <= 240 ) { $battery_percentage = 0; } else { $battery_percentage = (100 * ($battery_range / $voltage_range)); } } echo $battery_percentage;
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/CRq6h
function name:  (null)
number of ops:  22
compiled vars:  !0 = $battery, !1 = $voltage_full, !2 = $voltage_empty, !3 = $voltage_range, !4 = $battery_range, !5 = $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                                              ~9      !1, !2
          4        ASSIGN                                                   !3, ~9
    7     5        CAST                                          4  ~11     !0
          6        ASSIGN                                                   !0, ~11
    8     7        SUB                                              ~13     !0, !2
          8        ASSIGN                                                   !4, ~13
   10     9        IS_SMALLER_OR_EQUAL                                      !1, !0
         10      > JMPZ                                                     ~15, ->13
   11    11    >   ASSIGN                                                   !5, 100
         12      > JMP                                                      ->20
   14    13    >   IS_SMALLER_OR_EQUAL                                      !0, 240
         14      > JMPZ                                                     ~17, ->17
   15    15    >   ASSIGN                                                   !5, 0
         16      > JMP                                                      ->20
   18    17    >   DIV                                              ~19     !4, !3
         18        MUL                                              ~20     ~19, 100
         19        ASSIGN                                                   !5, ~20
   22    20    >   ECHO                                                     !5
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.87 ms | 1394 KiB | 13 Q