3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class a { function __toString() { static $i = 0; $a = ['', 'a']; $r = $a[$i]; $i++; return $r; } } $a = new a; var_dump('' == $a and 'a' == $a); var_dump('' === (string)$a and 'a' === (string)$a);
based on EjVof
Output for 7.1.0 - 7.2.0
bool(true) Notice: Undefined offset: 2 in /in/OuP0K on line 8 Recoverable fatal error: Method a::__toString() must return a string value in /in/OuP0K on line 15
Process exited with code 255.
Output for 5.4.0 - 7.0.20
bool(true) Notice: Undefined offset: 2 in /in/OuP0K on line 8 Catchable fatal error: Method a::__toString() must return a string value in /in/OuP0K on line 15
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/OuP0K on line 7
Process exited with code 255.