3v4l.org

run code in 300+ 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:  75
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                                               'sprintf'
         20        SEND_VAL                                                 '%25s+%25s'
         21        INIT_FCALL                                               'round'
         22        INIT_FCALL                                               'pow'
         23        SEND_VAL                                                 1024
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $15     
         26        DIV                                              ~16     !0, $15
         27        SEND_VAL                                                 ~16
         28        SEND_VAL                                                 2
         29        DO_ICALL                                         $17     
         30        SEND_VAR                                                 $17
         31        FETCH_DIM_R                                      ~18     !1, !2
         32        SEND_VAL                                                 ~18
         33        DO_ICALL                                         $19     
         34      > RETURN                                                   $19
   11    35*       ASSIGN                                                   !3, 0
   13    36*       JMP                                                      ->40
   14    37*       DIV                                              ~21     !0, 1024
         38*       ASSIGN                                                   !0, ~21
   15    39*       PRE_INC                                                  !3
   13    40*       DIV                                              ~24     !0, 1024
         41*       IS_SMALLER                                               0.9, ~24
         42*       JMPNZ                                                    ~25, ->37
   19    43*       JMPZ                                                     <true>, ->46
   20    44*       QM_ASSIGN                                        ~26     9223372036854775807
         45*       JMP                                                      ->56
   21    46*       INIT_FCALL                                               'decbin'
         47*       SEND_VAL                                                 -1
         48*       DO_ICALL                                         $27     
         49*       STRLEN                                           ~28     $27
         50*       IS_IDENTICAL                                             ~28, 32
         51*       JMPZ                                                     ~29, ->54
         52*       QM_ASSIGN                                        ~30     2147483647
         53*       JMP                                                      ->55
         54*       QM_ASSIGN                                        ~30     9223372036854775807
         55*       QM_ASSIGN                                        ~26     ~30
   19    56*       ASSIGN                                                   !4, ~26
   23    57*       IS_SMALLER                                               !0, 0
         58*       JMPZ                                                     ~32, ->64
         59*       ADD                                              ~33     !4, 1
         60*       MUL                                              ~34     ~33, 2
         61*       ADD                                              ~35     !0, ~34
         62*       QM_ASSIGN                                        ~36     ~35
         63*       JMP                                                      ->65
         64*       QM_ASSIGN                                        ~36     !0
         65*       ASSIGN                                                   !0, ~36
   25    66*       INIT_FCALL                                               'round'
         67*       SEND_VAR                                                 !0
         68*       SEND_VAL                                                 2
         69*       DO_ICALL                                         $38     
         70*       CONCAT                                           ~39     $38, '+'
         71*       FETCH_DIM_R                                      ~40     !1, !3
         72*       CONCAT                                           ~41     ~39, ~40
         73*       RETURN                                                   ~41
   26    74*     > RETURN                                                   null

End of function fm_get_filesize

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.49 ms | 1403 KiB | 26 Q