3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tst = '!!!!'; $a = '@@@'; $template = '{{$tst}}test{{$a}}'; $x = preg_match_all("/{{(.*?)}}/", $template, $m); echo $x; if ($x) { print_r($m); foreach ($m[1] as $i => $varname) { echo strval($varname).PHP_EOL.$m[0][$i].'===='.sprintf('$%s', $varname).PHP_EOL; $template = str_replace($m[0][$i], $$varname, $template); } } echo $template;
Output for 5.0.4 - 7.1.0
2Array ( [0] => Array ( [0] => {{$tst}} [1] => {{$a}} ) [1] => Array ( [0] => $tst [1] => $a ) ) $tst {{$tst}}====$$tst Notice: Undefined variable: $tst in /in/IoWru on line 13 $a {{$a}}====$$a Notice: Undefined variable: $a in /in/IoWru on line 13 test
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.0.3
2Array ( [0] => Array ( [0] => {{$tst}} [1] => {{$a}} ) [1] => Array ( [0] => $tst [1] => $a ) ) $tst {{$tst}}====$$tst Notice: Undefined variable: $tst in /in/IoWru on line 13 $a {{$a}}====$$a Notice: Undefined variable: $a in /in/IoWru on line 13 test
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
2Array ( [0] => Array ( [0] => {{$tst}} [1] => {{$a}} ) [1] => Array ( [0] => $tst [1] => $a ) ) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/IoWru on line 12 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/IoWru on line 12 $tstPHP_EOL{{$tst}}====$$tstPHP_EOL Notice: Undefined variable: $tst in /in/IoWru on line 13 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/IoWru on line 12 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/IoWru on line 12 $aPHP_EOL{{$a}}====$$aPHP_EOL Notice: Undefined variable: $a in /in/IoWru on line 13 test