3v4l.org

run code in 300+ 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($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/OUJaH
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 = 17, Position 2 = 34
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OUJaH
function name:  bytes_to_int
number of ops:  42
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        INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%2F%5B%5Ebkmgtpezy%5D%2Fi'
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9        ASSIGN                                                   !1, $3
    8    10        INIT_FCALL                                               'preg_replace'
         11        SEND_VAL                                                 '%2F%5B%5E0-9%5C.%5D%2F'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $5      
         15        ASSIGN                                                   !0, $5
   10    16      > JMPZ                                                     !1, ->34
   11    17    >   INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'round'
         19        INIT_FCALL                                               'pow'
         20        SEND_VAL                                                 1024
         21        INIT_FCALL                                               'stripos'
         22        SEND_VAL                                                 'bkmgtpezy'
         23        FETCH_DIM_R                                      ~7      !1, 0
         24        SEND_VAL                                                 ~7
         25        DO_ICALL                                         $8      
         26        SEND_VAR                                                 $8
         27        DO_ICALL                                         $9      
         28        MUL                                              ~10     !0, $9
         29        SEND_VAL                                                 ~10
         30        DO_ICALL                                         $11     
         31        SEND_VAR                                                 $11
         32        DO_ICALL                                                 
   10    33      > JMP                                                      ->40
   14    34    >   INIT_FCALL                                               'var_dump'
         35        INIT_FCALL                                               'round'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $13     
         38        SEND_VAR                                                 $13
         39        DO_ICALL                                                 
   16    40    >   ECHO                                                     '%0A%0A'
   17    41      > RETURN                                                   null

End of function bytes_to_int

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.2 ms | 1022 KiB | 22 Q