3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseDbString(string $value = 'Looking for a good {{ $pippo }}'){ $pippo='Pizza'; return preg_replace_callback('/{{(.*?)}}/', function($res) use ($pippo) { return "${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());
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in /in/D2PG7 on line 6 Warning: Undefined variable $$pippo in /in/D2PG7 on line 6 string(19) "Looking for a good "

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.43 ms | 401 KiB | 8 Q