3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tst = '!!!!'; $a = '@@@'; $template = '{{$tst}}test{{$a}}'; if (preg_match_all("/{{(.*?)}}/", $template, $m)) { foreach ($m[1] as $i => $varname) { echo $varname.PHP_EOL.$m[0][$i].'===='.sprintf('$%s', $varname).PHP_EOL; $x = strval($varname); $template = str_replace($m[0][$i], sprintf('$%s', $$varname), $template); } } $x = '###'.strval($a).PHP_EOL; echo $x; echo $template;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 41
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 41
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 42
filename:       /in/o1D1G
function name:  (null)
number of ops:  49
compiled vars:  !0 = $tst, !1 = $a, !2 = $template, !3 = $m, !4 = $varname, !5 = $i, !6 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%21%21%21%21'
    4     1        ASSIGN                                                   !1, '%40%40%40'
    5     2        ASSIGN                                                   !2, '%7B%7B%24tst%7D%7Dtest%7B%7B%24a%7D%7D'
    7     3        INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%2F%7B%7B%28.%2A%3F%29%7D%7D%2F'
          5        SEND_VAR                                                 !2
          6        SEND_REF                                                 !3
          7        DO_ICALL                                         $10     
          8      > JMPZ                                                     $10, ->42
    8     9    >   FETCH_DIM_R                                      ~11     !3, 1
         10      > FE_RESET_R                                       $12     ~11, ->41
         11    > > FE_FETCH_R                                       ~13     $12, !4, ->41
         12    >   ASSIGN                                                   !5, ~13
    9    13        CONCAT                                           ~15     !4, '%0A'
         14        FETCH_DIM_R                                      ~16     !3, 0
         15        FETCH_DIM_R                                      ~17     ~16, !5
         16        CONCAT                                           ~18     ~15, ~17
         17        CONCAT                                           ~19     ~18, '%3D%3D%3D%3D'
         18        INIT_FCALL                                               'sprintf'
         19        SEND_VAL                                                 '%24%25s'
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                         $20     
         22        CONCAT                                           ~21     ~19, $20
         23        CONCAT                                           ~22     ~21, '%0A'
         24        ECHO                                                     ~22
   10    25        CAST                                          6  ~23     !4
         26        ASSIGN                                                   !6, ~23
   11    27        INIT_FCALL                                               'str_replace'
         28        FETCH_DIM_R                                      ~25     !3, 0
         29        FETCH_DIM_R                                      ~26     ~25, !5
         30        SEND_VAL                                                 ~26
         31        INIT_FCALL                                               'sprintf'
         32        SEND_VAL                                                 '%24%25s'
         33        FETCH_R                      local               ~27     !4
         34        SEND_VAL                                                 ~27
         35        DO_ICALL                                         $28     
         36        SEND_VAR                                                 $28
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $29     
         39        ASSIGN                                                   !2, $29
    8    40      > JMP                                                      ->11
         41    >   FE_FREE                                                  $12
   14    42    >   CAST                                          6  ~31     !1
         43        CONCAT                                           ~32     '%23%23%23', ~31
         44        CONCAT                                           ~33     ~32, '%0A'
         45        ASSIGN                                                   !6, ~33
   15    46        ECHO                                                     !6
   16    47        ECHO                                                     !2
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.33 ms | 1392 KiB | 19 Q