3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set("precision", 52); 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); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; } echo formatBytes(1317474, 1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OiFYV
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'precision'
          2        SEND_VAL                                                 52
          3        DO_ICALL                                                 
   17     4        INIT_FCALL                                               'formatbytes'
          5        SEND_VAL                                                 1317474
          6        SEND_VAL                                                 1
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9      > 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/OiFYV
function name:  formatBytes
number of ops:  44
compiled vars:  !0 = $bytes, !1 = $precision, !2 = $units, !3 = $pow
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    6     2        ASSIGN                                                   !2, <array>
    8     3        INIT_FCALL                                               'max'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
    9     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
   10    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
   12    30        INIT_FCALL                                               'pow'
         31        SEND_VAL                                                 1024
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                         $17     
         34        ASSIGN_OP                                     4          !0, $17
   14    35        INIT_FCALL                                               'round'
         36        SEND_VAR                                                 !0
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                         $19     
         39        CONCAT                                           ~20     $19, '+'
         40        FETCH_DIM_R                                      ~21     !2, !3
         41        CONCAT                                           ~22     ~20, ~21
         42      > RETURN                                                   ~22
   15    43*     > RETURN                                                   null

End of function formatbytes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.79 ms | 1403 KiB | 28 Q