3v4l.org

run code in 300+ PHP versions simultaneously
<?php function formatBytes($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]; } echo formatBytes(24962496);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sP0ON
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'formatbytes'
          1        SEND_VAL                                                 24962496
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function formatbytes:
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/sP0ON
function name:  formatBytes
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 formatbytes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.59 ms | 1402 KiB | 24 Q