3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class myIterator implements Iterator { private $position = 0; private $array = array( new stdClass(), new stdClass(), new stdClass(), ); 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 as $t) { echo $t; }
Output for 5.4.0 - 5.4.29
Parse error: syntax error, unexpected 'new' (T_NEW), expecting ')' in /in/jg7G1 on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_NEW, expecting ')' in /in/jg7G1 on line 6
Process exited with code 255.