3v4l.org

run code in 300+ PHP versions simultaneously
<?php // String manipulation (explode and manual comparison) $sstart = microtime(true); for ($i = 0; $i < 100000; $i++) { $uri = 'user/123'; $segments = explode('/', $uri); if ($segments[0] === 'user' && is_numeric($segments[1])) { $id = $segments[1]; } } $string = (microtime(true) - $sstart); echo 'String manipulation: ' . $string . ' seconds'.PHP_EOL; // Regex equivalent $rstart = microtime(true); for ($i = 0; $i < 100000; $i++) { $uri = 'user/123'; if (preg_match('#^user/(\d+)$#', $uri, $matches)) { $id = $matches[1]; } } $regex = (microtime(true) - $rstart); echo 'Regex: ' . $regex . ' seconds'.PHP_EOL; echo 'Diff: '.((($regex - $string) / $string) * 100).'%';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 6
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 41
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 41
Branch analysis from position: 53
Branch analysis from position: 41
Branch analysis from position: 50
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 6
Branch analysis from position: 26
Branch analysis from position: 6
Branch analysis from position: 23
Branch analysis from position: 20
filename:       /in/Zi9Jc
function name:  (null)
number of ops:  69
compiled vars:  !0 = $sstart, !1 = $i, !2 = $uri, !3 = $segments, !4 = $id, !5 = $string, !6 = $rstart, !7 = $matches, !8 = $regex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $9      
          3        ASSIGN                                                   !0, $9
    5     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->24
    6     6    >   ASSIGN                                                   !2, 'user%2F123'
    7     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%2F'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $13     
         11        ASSIGN                                                   !3, $13
    8    12        FETCH_DIM_R                                      ~15     !3, 0
         13        IS_IDENTICAL                                     ~16     ~15, 'user'
         14      > JMPZ_EX                                          ~16     ~16, ->20
         15    >   INIT_FCALL                                               'is_numeric'
         16        FETCH_DIM_R                                      ~17     !3, 1
         17        SEND_VAL                                                 ~17
         18        DO_ICALL                                         $18     
         19        BOOL                                             ~16     $18
         20    > > JMPZ                                                     ~16, ->23
    9    21    >   FETCH_DIM_R                                      ~19     !3, 1
         22        ASSIGN                                                   !4, ~19
    5    23    >   PRE_INC                                                  !1
         24    >   IS_SMALLER                                               !1, 100000
         25      > JMPNZ                                                    ~22, ->6
   12    26    >   INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $23     
         29        SUB                                              ~24     $23, !0
         30        ASSIGN                                                   !5, ~24
   13    31        CONCAT                                           ~26     'String+manipulation%3A+', !5
         32        CONCAT                                           ~27     ~26, '+seconds'
         33        CONCAT                                           ~28     ~27, '%0A'
         34        ECHO                                                     ~28
   16    35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $29     
         38        ASSIGN                                                   !6, $29
   17    39        ASSIGN                                                   !1, 0
         40      > JMP                                                      ->51
   18    41    >   ASSIGN                                                   !2, 'user%2F123'
   19    42        INIT_FCALL                                               'preg_match'
         43        SEND_VAL                                                 '%23%5Euser%2F%28%5Cd%2B%29%24%23'
         44        SEND_VAR                                                 !2
         45        SEND_REF                                                 !7
         46        DO_ICALL                                         $33     
         47      > JMPZ                                                     $33, ->50
   20    48    >   FETCH_DIM_R                                      ~34     !7, 1
         49        ASSIGN                                                   !4, ~34
   17    50    >   PRE_INC                                                  !1
         51    >   IS_SMALLER                                               !1, 100000
         52      > JMPNZ                                                    ~37, ->41
   23    53    >   INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $38     
         56        SUB                                              ~39     $38, !6
         57        ASSIGN                                                   !8, ~39
   24    58        CONCAT                                           ~41     'Regex%3A+', !8
         59        CONCAT                                           ~42     ~41, '+seconds'
         60        CONCAT                                           ~43     ~42, '%0A'
         61        ECHO                                                     ~43
   26    62        SUB                                              ~44     !8, !5
         63        DIV                                              ~45     ~44, !5
         64        MUL                                              ~46     ~45, 100
         65        CONCAT                                           ~47     'Diff%3A+', ~46
         66        CONCAT                                           ~48     ~47, '%25'
         67        ECHO                                                     ~48
         68      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.11 ms | 1441 KiB | 17 Q