3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class myIterator implements Iterator { private $position = 0; private $array = array( "firstelement", "secondelement", "lastelement", ); public function __construct() { $this->position = 0; } function rewind() { var_dump(__METHOD__); $this->position = 0; } function current() { var_dump(__METHOD__); return $this->array[$this->position]; } function key() { var_dump(__METHOD__); return $this->position; } function next() { var_dump(__METHOD__); ++$this->position; } function valid() { var_dump(__METHOD__); return isset($this->array[$this->position]); } } $i = new myIterator(); foreach ($i => $t) { var_dump($t); }
Output for 5.4.0 - 5.4.29
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/qPZfD on line 43
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_DOUBLE_ARROW in /in/qPZfD on line 43
Process exited with code 255.