3v4l.org

run code in 500+ PHP versions simultaneously
<?php function foo() { return "Wykopek"; } function bar($a) { return $a . ' harnasia'; } $template = "Michał {{foo}} kończył {{bar, 5}}."; $result = preg_replace_callback('/{{([^}]+)}}/', function($matches) { $parts = explode(', ', $matches[1]); $functionName = array_shift($parts); return $functionName(...$parts); }, $template); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dl10n
function name:  (null)
number of ops:  10
compiled vars:  !0 = $template, !1 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, 'Micha%C5%82+%7B%7Bfoo%7D%7D+ko%C5%84czy%C5%82+%7B%7Bbar%2C+5%7D%7D.'
   13     1        INIT_FCALL                                                   'preg_replace_callback'
          2        SEND_VAL                                                     '%2F%7B%7B%28%5B%5E%7D%5D%2B%29%7D%7D%2F'
          3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   19     4        SEND_VAL                                                     ~3
          5        SEND_VAR                                                     !0
   13     6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !1, $4
   22     8        ECHO                                                         !1
   23     9      > 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/Dl10n
function name:  {closure:/in/Dl10n:13}
number of ops:  17
compiled vars:  !0 = $matches, !1 = $parts, !2 = $functionName
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%2C+'
          3        FETCH_DIM_R                                          ~3      !0, 1
          4        SEND_VAL                                                     ~3
          5        DO_ICALL                                             $4      
          6        ASSIGN                                                       !1, $4
   16     7        INIT_FCALL                                                   'array_shift'
          8        SEND_REF                                                     !1
          9        DO_ICALL                                             $6      
         10        ASSIGN                                                       !2, $6
   17    11        INIT_DYNAMIC_CALL                                            !2
         12        SEND_UNPACK                                                  !1
         13        CHECK_UNDEF_ARGS                                             
         14        DO_FCALL                                          1  $8      
         15      > RETURN                                                       $8
   19    16*     > RETURN                                                       null

End of Dynamic Function 0

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dl10n
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                       'Wykopek'
    5     1*     > RETURN                                                       null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dl10n
function name:  bar
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        CONCAT                                               ~1      !0, '+harnasia'
          2      > RETURN                                                       ~1
    9     3*     > RETURN                                                       null

End of function bar

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.4 ms | 2051 KiB | 16 Q