3v4l.org

run code in 300+ PHP versions simultaneously
<?php $params = [':foo' => null]; $sql = 'select * from test where foo = :foo'; $sql = preg_replace_callback( '/(?<!\b)(?<![:\\\]):(#?[a-zA-Z0-9_-]+)/', function ($match) use ($params) { return $params[$match[1]]; }, $sql ); var_dump($sql);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rM2m
function name:  (null)
number of ops:  14
compiled vars:  !0 = $params, !1 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 'select+%2A+from+test+where+foo+%3D+%3Afoo'
    7     2        INIT_FCALL                                               'preg_replace_callback'
    8     3        SEND_VAL                                                 '%2F%28%3F%3C%21%5Cb%29%28%3F%3C%21%5B%3A%5C%5C%5D%29%3A%28%23%3F%5Ba-zA-Z0-9_-%5D%2B%29%2F'
    9     4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !0
   13     6        SEND_VAL                                                 ~4
   14     7        SEND_VAR                                                 !1
    7     8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
   17    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
         13      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rM2m
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $match, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   12     2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_DIM_R                                      ~3      !1, ~2
          4      > RETURN                                                   ~3
   13     5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.6 ms | 1441 KiB | 16 Q