3v4l.org

run code in 500+ PHP versions simultaneously
<?php function fm_get_filesize($size) { $size = (float) $size; $size = (int) $size; $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $power = $size > 0 ? floor(log($size, 1024)) : 0; return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]); $i = 0; while (($size / 1024) > 0.9) { $size = $size / 1024; $i++; } // Fix 32bit integer overflow $int_max = defined('PHP_INT_MAX') ? PHP_INT_MAX : ((strlen(decbin(~0)) === 32) ? 2147483647 : 9223372036854775807); $size = ($size < 0) ? ($size + (2.0 * ($int_max + 1))) : $size; return round($size, 2).' '.$units[$i]; } echo fm_get_filesize(6565655656);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d0UBh
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                                   'fm_get_filesize'
          1        SEND_VAL                                                     6565655656
          2        DO_FCALL                                          0  $0      
          3        ECHO                                                         $0
          4      > RETURN                                                       1

Function fm_get_filesize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d0UBh
function name:  fm_get_filesize
number of ops:  73
compiled vars:  !0 = $size, !1 = $units, !2 = $power, !3 = $i, !4 = $int_max
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        CAST                                              5  ~5      !0
          2        ASSIGN                                                       !0, ~5
    6     3        CAST                                              4  ~7      !0
          4        ASSIGN                                                       !0, ~7
    7     5        ASSIGN                                                       !1, <array>
    8     6        IS_SMALLER                                                   0, !0
          7      > JMPZ                                                         ~10, ->17
          8    >   INIT_FCALL                                                   'floor'
          9        INIT_FCALL                                                   'log'
         10        SEND_VAR                                                     !0
         11        SEND_VAL                                                     1024
         12        DO_ICALL                                             $11     
         13        SEND_VAR                                                     $11
         14        DO_ICALL                                             $12     
         15        QM_ASSIGN                                            ~13     $12
         16      > JMP                                                          ->18
         17    >   QM_ASSIGN                                            ~13     0
         18    >   ASSIGN                                                       !2, ~13
    9    19        INIT_FCALL                                                   'round'
         20        INIT_FCALL                                                   'pow'
         21        SEND_VAL                                                     1024
         22        SEND_VAR                                                     !2
         23        DO_ICALL                                             $15     
         24        DIV                                                  ~16     !0, $15
         25        SEND_VAL                                                     ~16
         26        SEND_VAL                                                     2
         27        DO_ICALL                                             $17     
         28        FETCH_DIM_R                                          ~18     !1, !2
         29        ROPE_INIT                                         3  ~20     $17
         30        ROPE_ADD                                          1  ~20     ~20, '+'
         31        ROPE_END                                          2  ~19     ~20, ~18
         32      > RETURN                                                       ~19
   11    33*       ASSIGN                                                       !3, 0
   13    34*       JMP                                                          ->38
   14    35*       DIV                                                  ~23     !0, 1024
         36*       ASSIGN                                                       !0, ~23
   15    37*       PRE_INC                                                      !3
   13    38*       DIV                                                  ~26     !0, 1024
         39*       IS_SMALLER                                                   0.9, ~26
         40*       JMPNZ                                                        ~27, ->35
   19    41*       JMPZ                                                         <true>, ->44
   20    42*       QM_ASSIGN                                            ~28     9223372036854775807
         43*       JMP                                                          ->54
   21    44*       INIT_FCALL                                                   'decbin'
         45*       SEND_VAL                                                     -1
         46*       DO_ICALL                                             $29     
         47*       STRLEN                                               ~30     $29
         48*       IS_IDENTICAL                                                 ~30, 32
         49*       JMPZ                                                         ~31, ->52
         50*       QM_ASSIGN                                            ~32     2147483647
         51*       JMP                                                          ->53
         52*       QM_ASSIGN                                            ~32     9223372036854775807
         53*       QM_ASSIGN                                            ~28     ~32
   19    54*       ASSIGN                                                       !4, ~28
   23    55*       IS_SMALLER                                                   !0, 0
         56*       JMPZ                                                         ~34, ->62
         57*       ADD                                                  ~35     !4, 1
         58*       MUL                                                  ~36     ~35, 2
         59*       ADD                                                  ~37     !0, ~36
         60*       QM_ASSIGN                                            ~38     ~37
         61*       JMP                                                          ->63
         62*       QM_ASSIGN                                            ~38     !0
         63*       ASSIGN                                                       !0, ~38
   25    64*       INIT_FCALL                                                   'round'
         65*       SEND_VAR                                                     !0
         66*       SEND_VAL                                                     2
         67*       DO_ICALL                                             $40     
         68*       CONCAT                                               ~41     $40, '+'
         69*       FETCH_DIM_R                                          ~42     !1, !3
         70*       CONCAT                                               ~43     ~41, ~42
         71*       RETURN                                                       ~43
   26    72*     > RETURN                                                       null

End of function fm_get_filesize

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.47 ms | 1468 KiB | 19 Q