run code in 200+ php & hhvm versions
Bugs & Features
<?php function parseDbString(string $value = 'Looking for a good {{ $pippo }}'){ $pippo='Pizza'; return preg_replace_callback('/{{(.*?)}}/', function($res) use ($pippo) { return $res;//trim($res[1]); // $val=${trim($res[1])}; Returns "Undefined variable: $pippo" $val=${trim($res[1])}; // Returns "Looking for a good Pizza" return isset($val) ? $val : $res[0]; },$value); } var_dump(parseDbString());
based on 6F19b
Output for 7.0.28 - 7.3.0rc4
Notice: Array to string conversion in /in/n45ZN on line 10 string(24) "Looking for a good Array"
Output for 5.6.38
Fatal error: Default value for parameters with a class type hint can only be NULL in /in/n45ZN on line 3
Process exited with code 255.