3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertToBytes($from){ $number=substr($from,0,-2); switch(strtoupper(substr($from,-2))){ case "KB": return $number*1024; case "MB": return $number*pow(1024,2); case "GB": return $number*pow(1024,3); case "TB": return $number*pow(1024,4); case "PB": return $number*pow(1024,5); default: return $from; } } echo convertToBytes("2GB"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44bv0
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'converttobytes'
          1        SEND_VAL                                                 '2GB'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   22     4      > RETURN                                                   1

Function converttobytes:
Finding entry points
Branch analysis from position: 0
7 jumps found. (Code = 188) Position 1 = 26, Position 2 = 29, Position 3 = 36, Position 4 = 43, Position 5 = 50, Position 6 = 57, Position 7 = 15
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 43
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 50
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 50
Branch analysis from position: 43
Branch analysis from position: 36
Branch analysis from position: 29
Branch analysis from position: 26
filename:       /in/44bv0
function name:  convertToBytes
number of ops:  61
compiled vars:  !0 = $from, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 -2
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !1, $2
    5     7        INIT_FCALL                                               'strtoupper'
          8        INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 -2
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                         $5      
         14      > SWITCH_STRING                                            $5, [ 'KB':->26, 'MB':->29, 'GB':->36, 'TB':->43, 'PB':->50, ], ->57
    6    15    >   CASE                                                     $5, 'KB'
         16      > JMPNZ                                                    ~6, ->26
    8    17    >   CASE                                                     $5, 'MB'
         18      > JMPNZ                                                    ~6, ->29
   10    19    >   CASE                                                     $5, 'GB'
         20      > JMPNZ                                                    ~6, ->36
   12    21    >   CASE                                                     $5, 'TB'
         22      > JMPNZ                                                    ~6, ->43
   14    23    >   CASE                                                     $5, 'PB'
         24      > JMPNZ                                                    ~6, ->50
         25    > > JMP                                                      ->57
    7    26    >   MUL                                              ~7      !1, 1024
         27        FREE                                                     $5
         28      > RETURN                                                   ~7
    9    29    >   INIT_FCALL                                               'pow'
         30        SEND_VAL                                                 1024
         31        SEND_VAL                                                 2
         32        DO_ICALL                                         $8      
         33        MUL                                              ~9      !1, $8
         34        FREE                                                     $5
         35      > RETURN                                                   ~9
   11    36    >   INIT_FCALL                                               'pow'
         37        SEND_VAL                                                 1024
         38        SEND_VAL                                                 3
         39        DO_ICALL                                         $10     
         40        MUL                                              ~11     !1, $10
         41        FREE                                                     $5
         42      > RETURN                                                   ~11
   13    43    >   INIT_FCALL                                               'pow'
         44        SEND_VAL                                                 1024
         45        SEND_VAL                                                 4
         46        DO_ICALL                                         $12     
         47        MUL                                              ~13     !1, $12
         48        FREE                                                     $5
         49      > RETURN                                                   ~13
   15    50    >   INIT_FCALL                                               'pow'
         51        SEND_VAL                                                 1024
         52        SEND_VAL                                                 5
         53        DO_ICALL                                         $14     
         54        MUL                                              ~15     !1, $14
         55        FREE                                                     $5
         56      > RETURN                                                   ~15
   17    57    >   FREE                                                     $5
         58      > RETURN                                                   !0
         59*       FREE                                                     $5
   19    60*     > RETURN                                                   null

End of function converttobytes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.64 ms | 1407 KiB | 20 Q