3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class obj { function __tostring() { $GLOBALS['a'] = 'hi'; } } $a = [0, new obj, 2]; $b = ["Nula", "Jedna", "Dva"]; var_dump($a); str_replace($a, $b, "1"); var_dump($a);
based on 6icnd
Output for 7.1.0 - 7.2.0
array(3) { [0]=> int(0) [1]=> object(obj)#1 (0) { } [2]=> int(2) } Recoverable fatal error: Method obj::__toString() must return a string value in /in/W51BS on line 13
Process exited with code 255.
Output for 5.4.11 - 7.0.20
array(3) { [0]=> int(0) [1]=> object(obj)#1 (0) { } [2]=> int(2) } Catchable fatal error: Method obj::__toString() must return a string value in /in/W51BS on line 13
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/W51BS on line 9
Process exited with code 255.