3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo sqlTemplate("{{1}} {[2]} {{3:BLABLABLA}}",array(null,"HELLO",array(1,323,452),false)); function sqlTemplate($query,$vars){ $replace = function($matches) use ($vars) { $varName = trim($matches[2]); if(count($matches)==5){ return isset($vars[$varName])&&$vars[$varName]?$matches[4]:""; }else if($matches[1] == '['){ return implode(',',$vars[$varName]); }else if($matches[1] == '{'){ return $vars[$varName]; }else{ return $matches[0]; } }; return preg_replace_callback('~\{([\[\{])([a-z0-9\_\-]+)(\:([^\}]*))?[\]\}]\}~i',$replace, $query); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aX0Lq
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'sqlTemplate'
          1        SEND_VAL_EX                                              '%7B%7B1%7D%7D+%7B%5B2%5D%7D+%7B%7B3%3ABLABLABLA%7D%7D'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   19     5      > RETURN                                                   1

Function sqltemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aX0Lq
function name:  sqlTemplate
number of ops:  12
compiled vars:  !0 = $query, !1 = $vars, !2 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaX0Lq%3A6%240'
          3        BIND_LEXICAL                                             ~3, !1
          4        ASSIGN                                                   !2, ~3
   18     5        INIT_FCALL                                               'preg_replace_callback'
          6        SEND_VAL                                                 '%7E%5C%7B%28%5B%5C%5B%5C%7B%5D%29%28%5Ba-z0-9%5C_%5C-%5D%2B%29%28%5C%3A%28%5B%5E%5C%7D%5D%2A%29%29%3F%5B%5C%5D%5C%7D%5D%5C%7D%7Ei'
          7        SEND_VAR                                                 !2
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10      > RETURN                                                   $5
   19    11*     > RETURN                                                   null

End of function sqltemplate

Function %00%7Bclosure%7D%2Fin%2FaX0Lq%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aX0Lq
function name:  {closure}
number of ops:  40
compiled vars:  !0 = $matches, !1 = $vars, !2 = $varName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        INIT_FCALL                                               'trim'
          3        FETCH_DIM_R                                      ~3      !0, 2
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !2, $4
    8     7        COUNT                                            ~6      !0
          8        IS_EQUAL                                                 ~6, 5
          9      > JMPZ                                                     ~7, ->21
    9    10    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, !2
         11      > JMPZ_EX                                          ~8      ~8, ->14
         12    >   FETCH_DIM_R                                      ~9      !1, !2
         13        BOOL                                             ~8      ~9
         14    > > JMPZ                                                     ~8, ->18
         15    >   FETCH_DIM_R                                      ~10     !0, 4
         16        QM_ASSIGN                                        ~11     ~10
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~11     ''
         19    > > RETURN                                                   ~11
         20*       JMP                                                      ->39
   10    21    >   FETCH_DIM_R                                      ~12     !0, 1
         22        IS_EQUAL                                                 ~12, '%5B'
         23      > JMPZ                                                     ~13, ->31
   11    24    >   INIT_FCALL                                               'implode'
         25        SEND_VAL                                                 '%2C'
         26        FETCH_DIM_R                                      ~14     !1, !2
         27        SEND_VAL                                                 ~14
         28        DO_ICALL                                         $15     
         29      > RETURN                                                   $15
         30*       JMP                                                      ->39
   12    31    >   FETCH_DIM_R                                      ~16     !0, 1
         32        IS_EQUAL                                                 ~16, '%7B'
         33      > JMPZ                                                     ~17, ->37
   13    34    >   FETCH_DIM_R                                      ~18     !1, !2
         35      > RETURN                                                   ~18
         36*       JMP                                                      ->39
   15    37    >   FETCH_DIM_R                                      ~19     !0, 0
         38      > RETURN                                                   ~19
   17    39*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaX0Lq%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.6 ms | 1400 KiB | 19 Q