3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stringInterpolate($str, array $vars) { return preg_replace_callback('/\{\$(\w+)\}/', function($matches) use($vars){ return $vars[$matches[1]]; }, $str); } echo stringInterpolate('name: {$name}, surname: {$surname}', array('name' => 'foo', 'surname' => 'Bar'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FnZea
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'stringinterpolate'
          1        SEND_VAL                                                 'name%3A+%7B%24name%7D%2C+surname%3A+%7B%24surname%7D'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function stringinterpolate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FnZea
function name:  stringInterpolate
number of ops:  11
compiled vars:  !0 = $str, !1 = $vars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%5C%7B%5C%24%28%5Cw%2B%29%5C%7D%2F'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFnZea%3A5%240'
          5        BIND_LEXICAL                                             ~2, !1
    7     6        SEND_VAL                                                 ~2
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
    8    10*     > RETURN                                                   null

End of function stringinterpolate

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

End of function %00%7Bclosure%7D%2Fin%2FFnZea%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.76 ms | 1399 KiB | 16 Q