3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "I need to replace {X} and {Y}"; $X = 'something'; $Y = 'something else'; function parse($string) { $varName = sprintf('%s%s%s%s%s%s%s%s', chr(36), chr(71), chr(76), chr(79), chr(66), chr(65), chr(76), chr(83)); var_dump($varName['X']); return; preg_match_all('/\{(.*?)\}/', $string, $matches); foreach ($matches[1] as $value) { $string = str_replace('{'.$value.'}', ${$value}, $string); } return $string; } echo parse($string);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/LrfVB:10 Stack trace: #0 /in/LrfVB(25): parse('I need to repla...') #1 {main} thrown in /in/LrfVB on line 10
Process exited with code 255.

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:
40.95 ms | 401 KiB | 8 Q