3v4l.org

run code in 500+ PHP versions simultaneously
<?php function bytes_to_int($size) { var_dump($size); // Remove the non-unit characters from the size. $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-numeric characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); if ($unit) { var_dump(round($size * pow(1024, stripos('bkmgtpezy', $unit[0])))); } else { var_dump(round((float) $size)); } print "\n\n"; } bytes_to_int('12,2'); bytes_to_int('12,2 b'); bytes_to_int(''); bytes_to_int('m');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F83lJ
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                                   'bytes_to_int'
          1        SEND_VAL                                                     '12%2C2'
          2        DO_FCALL                                          0          
   20     3        INIT_FCALL                                                   'bytes_to_int'
          4        SEND_VAL                                                     '12%2C2+b'
          5        DO_FCALL                                          0          
   21     6        INIT_FCALL                                                   'bytes_to_int'
          7        SEND_VAL                                                     ''
          8        DO_FCALL                                          0          
   22     9        INIT_FCALL                                                   'bytes_to_int'
         10        SEND_VAL                                                     'm'
         11        DO_FCALL                                          0          
         12      > RETURN                                                       1

Function bytes_to_int:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F83lJ
function name:  bytes_to_int
number of ops:  37
compiled vars:  !0 = $size, !1 = $unit
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'var_dump'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                                     
    6     4        FRAMELESS_ICALL_3                preg_replace        ~3      '%2F%5B%5Ebkmgtpezy%5D%2Fi', ''
          5        OP_DATA                                                      !0
          6        ASSIGN                                                       !1, ~3
    8     7        FRAMELESS_ICALL_3                preg_replace        ~5      '%2F%5B%5E0-9%5C.%5D%2F', ''
          8        OP_DATA                                                      !0
          9        ASSIGN                                                       !0, ~5
   10    10      > JMPZ                                                         !1, ->28
   11    11    >   INIT_FCALL                                                   'var_dump'
         12        INIT_FCALL                                                   'round'
         13        INIT_FCALL                                                   'pow'
         14        SEND_VAL                                                     1024
         15        INIT_FCALL                                                   'stripos'
         16        SEND_VAL                                                     'bkmgtpezy'
         17        FETCH_DIM_R                                          ~7      !1, 0
         18        SEND_VAL                                                     ~7
         19        DO_ICALL                                             $8      
         20        SEND_VAR                                                     $8
         21        DO_ICALL                                             $9      
         22        MUL                                                  ~10     !0, $9
         23        SEND_VAL                                                     ~10
         24        DO_ICALL                                             $11     
         25        SEND_VAR                                                     $11
         26        DO_ICALL                                                     
   10    27      > JMP                                                          ->35
   14    28    >   INIT_FCALL                                                   'var_dump'
         29        INIT_FCALL                                                   'round'
         30        CAST                                              5  ~13     !0
         31        SEND_VAL                                                     ~13
         32        DO_ICALL                                             $14     
         33        SEND_VAR                                                     $14
         34        DO_ICALL                                                     
   16    35    >   ECHO                                                         '%0A%0A'
   17    36      > RETURN                                                       null

End of function bytes_to_int

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.96 ms | 2193 KiB | 21 Q