3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tst = '!!!!'; $a = '@@@'; $template = '{{$tst}}test{{$a}}'; if (preg_match_all("/{{(.*?)}}/", $template, $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); } } $x = '###'.strval($a).PHP_EOL; echo $x; echo $template;
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Undefined variable: $tst in /in/h4JfX on line 9 {{$tst}}====$$tst Notice: Undefined variable: $a in /in/h4JfX on line 9 {{$a}}====$$a ###@@@ {{$tst}}test{{$a}}
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.0.3
Notice: Undefined variable: $tst in /in/h4JfX on line 9 {{$tst}}====$$tst Notice: Undefined variable: $a in /in/h4JfX on line 9 {{$a}}====$$a ###@@@ {{$tst}}test{{$a}}
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Undefined variable: $tst in /in/h4JfX on line 9 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/h4JfX on line 9 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/h4JfX on line 9 PHP_EOL{{$tst}}====$$tstPHP_EOL Notice: Undefined variable: $a in /in/h4JfX on line 9 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/h4JfX on line 9 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/h4JfX on line 9 PHP_EOL{{$a}}====$$aPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/h4JfX on line 13 ###@@@PHP_EOL{{$tst}}test{{$a}}