3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Example implements Iterator { public $i = 0; public $prop = 'pie'; public function rewind() { $this->i = 0;} public function next() {} public function valid() { return ($this->i++ < 5); } public function key() { return 7; } public function current() { return $this->prop; } } $it = new Example; foreach ($it as &$current) { $current = str_rot13($current); } var_dump($it);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in /in/pdaNO:16 Stack trace: #0 {main} thrown in /in/pdaNO on line 16
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: An iterator cannot be used with foreach by reference in /in/pdaNO on line 18
Process exited with code 255.
Output for 5.2.0 - 5.6.28
Fatal error: An iterator cannot be used with foreach by reference in /in/pdaNO on line 16
Process exited with code 255.
Output for 5.0.0 - 5.1.6
object(Example)#1 (2) { ["i"]=> int(6) ["prop"]=> string(3) "pie" }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/pdaNO on line 3
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/pdaNO on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/pdaNO on line 3
Process exited with code 255.