3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fb1($bytes, $precision = 2) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); // Uncomment one of the following alternatives // $bytes /= pow(1024, $pow); // $bytes /= (1 << (10 * $pow)); return round($bytes, $precision) . ' ' . $units[$pow]; } function fb2($size, $precision = 2) { $base = log($size) / log(1024); $suffixes = array('', 'k', 'M', 'G', 'T'); return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; } function fb3($size) { $base = log($size) / log(1024); $suffix = array("", "k", "M", "G", "T")[floor($base)]; return pow(1024, $base - floor($base)) . $suffix; } echo fb1(24962496) . " 1 \n\n"; echo fb2(24962496) . " 2 \n\n"; echo fb3(24962496) . " 3 \n\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LQs4q
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'fb1'
          1        SEND_VAL                                                 24962496
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '+1+%0A%0A'
          4        ECHO                                                     ~1
   34     5        INIT_FCALL                                               'fb2'
          6        SEND_VAL                                                 24962496
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '+2+%0A%0A'
          9        ECHO                                                     ~3
   35    10        INIT_FCALL                                               'fb3'
         11        SEND_VAL                                                 24962496
         12        DO_FCALL                                      0  $4      
         13        CONCAT                                           ~5      $4, '+3+%0A%0A'
         14        ECHO                                                     ~5
         15      > RETURN                                                   1

Function fb1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LQs4q
function name:  fb1
number of ops:  39
compiled vars:  !0 = $bytes, !1 = $precision, !2 = $units, !3 = $pow
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        INIT_FCALL                                               'max'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
    7     8        INIT_FCALL                                               'floor'
          9      > JMPZ                                                     !0, ->15
         10    >   INIT_FCALL                                               'log'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        QM_ASSIGN                                        ~8      $7
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~8      0
         16    >   INIT_FCALL                                               'log'
         17        SEND_VAL                                                 1024
         18        DO_ICALL                                         $9      
         19        DIV                                              ~10     ~8, $9
         20        SEND_VAL                                                 ~10
         21        DO_ICALL                                         $11     
         22        ASSIGN                                                   !3, $11
    8    23        INIT_FCALL                                               'min'
         24        SEND_VAR                                                 !3
         25        COUNT                                            ~13     !2
         26        SUB                                              ~14     ~13, 1
         27        SEND_VAL                                                 ~14
         28        DO_ICALL                                         $15     
         29        ASSIGN                                                   !3, $15
   14    30        INIT_FCALL                                               'round'
         31        SEND_VAR                                                 !0
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                         $17     
         34        CONCAT                                           ~18     $17, '+'
         35        FETCH_DIM_R                                      ~19     !2, !3
         36        CONCAT                                           ~20     ~18, ~19
         37      > RETURN                                                   ~20
   15    38*     > RETURN                                                   null

End of function fb1

Function fb2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LQs4q
function name:  fb2
number of ops:  30
compiled vars:  !0 = $size, !1 = $precision, !2 = $base, !3 = $suffixes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
   19     2        INIT_FCALL                                               'log'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        INIT_FCALL                                               'log'
          6        SEND_VAL                                                 1024
          7        DO_ICALL                                         $5      
          8        DIV                                              ~6      $4, $5
          9        ASSIGN                                                   !2, ~6
   20    10        ASSIGN                                                   !3, <array>
   22    11        INIT_FCALL                                               'round'
         12        INIT_FCALL                                               'pow'
         13        SEND_VAL                                                 1024
         14        INIT_FCALL                                               'floor'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $9      
         17        SUB                                              ~10     !2, $9
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $12     
         23        INIT_FCALL                                               'floor'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $13     
         26        FETCH_DIM_R                                      ~14     !3, $13
         27        CONCAT                                           ~15     $12, ~14
         28      > RETURN                                                   ~15
   23    29*     > RETURN                                                   null

End of function fb2

Function fb3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LQs4q
function name:  fb3
number of ops:  25
compiled vars:  !0 = $size, !1 = $base, !2 = $suffix
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        INIT_FCALL                                               'log'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        INIT_FCALL                                               'log'
          5        SEND_VAL                                                 1024
          6        DO_ICALL                                         $4      
          7        DIV                                              ~5      $3, $4
          8        ASSIGN                                                   !1, ~5
   28     9        INIT_FCALL                                               'floor'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $7      
         12        FETCH_DIM_R                                      ~8      <array>, $7
         13        ASSIGN                                                   !2, ~8
   29    14        INIT_FCALL                                               'pow'
         15        SEND_VAL                                                 1024
         16        INIT_FCALL                                               'floor'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $10     
         19        SUB                                              ~11     !1, $10
         20        SEND_VAL                                                 ~11
         21        DO_ICALL                                         $12     
         22        CONCAT                                           ~13     $12, !2
         23      > RETURN                                                   ~13
   30    24*     > RETURN                                                   null

End of function fb3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.88 ms | 1407 KiB | 28 Q