3v4l.org

run code in 300+ PHP versions simultaneously
<?php $params = array('username' => "l33t"); $route = "/user/[a-z0-9:username]"; echo preg_replace_callback('~\[([a-z0-9\.\-_\+]+)\:([a-z0-9\_]+)\]~', function($matches) use(&$params) { if(isset($params[$matches[2]])){ return $matches[2]; }else{ return 'null'; } }, $route);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gE7eE
function name:  (null)
number of ops:  11
compiled vars:  !0 = $params, !1 = $route
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, '%2Fuser%2F%5Ba-z0-9%3Ausername%5D'
    4     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%7E%5C%5B%28%5Ba-z0-9%5C.%5C-_%5C%2B%5D%2B%29%5C%3A%28%5Ba-z0-9%5C_%5D%2B%29%5C%5D%7E'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgE7eE%3A4%240'
          5        BIND_LEXICAL                                             ~4, !0
   10     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $5      
          9        ECHO                                                     $5
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FgE7eE%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gE7eE
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $matches, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    5     2        FETCH_DIM_R                                      ~2      !0, 2
          3        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~2
          4      > JMPZ                                                     ~3, ->8
    6     5    >   FETCH_DIM_R                                      ~4      !0, 2
          6      > RETURN                                                   ~4
          7*       JMP                                                      ->9
    8     8    > > RETURN                                                   'null'
   10     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgE7eE%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.87 ms | 1395 KiB | 15 Q