3v4l.org

run code in 500+ PHP versions simultaneously
<?php function file_format_size($bytes, $decimals = 2) { $unit_list = array('B', 'KB', 'MB', 'GB', 'PB'); if ($bytes == 0) { return $bytes . ' ' . $unit_list[0]; } $unit_count = count($unit_list); for ($i = $unit_count - 1; $i >= 0; $i--) { $power = $i * 10; if (($bytes >> $power) >= 1) return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; } } foreach ([0, 10, 100, 1000, 1024, 10000, 100000, 1000000, 10000000] as $bytes) { var_export(file_format_size($bytes)); echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 10
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/s9AXo
function name:  (null)
number of ops:  12
compiled vars:  !0 = $bytes
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E > > FE_RESET_R                                           $1      <array>, ->10
          1    > > FE_FETCH_R                                                   $1, !0, ->10
   19     2    >   INIT_FCALL                                                   'var_export'
          3        INIT_FCALL                                                   'file_format_size'
          4        SEND_VAR                                                     !0
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
   20     8        ECHO                                                         '%0A'
   18     9      > JMP                                                          ->1
         10    >   FE_FREE                                                      $1
   21    11      > RETURN                                                       1

Function file_format_size:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 14
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 14
Branch analysis from position: 32
Branch analysis from position: 14
filename:       /in/s9AXo
function name:  file_format_size
number of ops:  33
compiled vars:  !0 = $bytes, !1 = $decimals, !2 = $unit_list, !3 = $unit_count, !4 = $i, !5 = $power
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      2
    4     2        ASSIGN                                                       !2, <array>
    6     3        IS_EQUAL                                                     !0, 0
          4      > JMPZ                                                         ~7, ->9
    7     5    >   CONCAT                                               ~8      !0, '+'
          6        FETCH_DIM_R                                          ~9      !2, 0
          7        CONCAT                                               ~10     ~8, ~9
          8      > RETURN                                                       ~10
   10     9    >   COUNT                                                ~11     !2
         10        ASSIGN                                                       !3, ~11
   11    11        SUB                                                  ~13     !3, 1
         12        ASSIGN                                                       !4, ~13
         13      > JMP                                                          ->30
   12    14    >   MUL                                                  ~15     !4, 10
         15        ASSIGN                                                       !5, ~15
   13    16        SR                                                   ~17     !0, !5
         17        IS_SMALLER_OR_EQUAL                                          1, ~17
         18      > JMPZ                                                         ~18, ->29
   14    19    >   INIT_FCALL                                                   'round'
         20        SL                                                   ~19     1, !5
         21        DIV                                                  ~20     !0, ~19
         22        SEND_VAL                                                     ~20
         23        SEND_VAR                                                     !1
         24        DO_ICALL                                             $21     
         25        CONCAT                                               ~22     $21, '+'
         26        FETCH_DIM_R                                          ~23     !2, !4
         27        CONCAT                                               ~24     ~22, ~23
         28      > RETURN                                                       ~24
   11    29    >   PRE_DEC                                                      !4
         30    >   IS_SMALLER_OR_EQUAL                                          0, !4
         31      > JMPNZ                                                        ~26, ->14
   16    32    > > RETURN                                                       null

End of function file_format_size

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
245.63 ms | 2004 KiB | 16 Q