3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Baz{} class Test implements Iterator { function key(){ return new Baz(); } function next(){} function valid(){ $this->count++; return $this->count < 4; } function current(){ return "foo"; } function rewind(){} } foreach(new Test as $x => $v) var_dump($x, $v);
based on XWE3L
Output for 5.5.0 - 7.2.8
Notice: Undefined property: Test::$count in /in/NtRMD on line 12 object(Baz)#3 (0) { } string(3) "foo" object(Baz)#4 (0) { } string(3) "foo" object(Baz)#3 (0) { } string(3) "foo"
Output for 5.0.0 - 5.4.45
Warning: Illegal type returned from Test::key() in /in/NtRMD on line 17 int(0) string(3) "foo" Warning: Illegal type returned from Test::key() in /in/NtRMD on line 17 int(0) string(3) "foo" Warning: Illegal type returned from Test::key() in /in/NtRMD on line 17 int(0) string(3) "foo"
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/NtRMD on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting '{' in /in/NtRMD on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/NtRMD on line 5
Process exited with code 255.