3v4l.org

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