3v4l.org

run code in 200+ 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]); } } $it = new myIterator; count($it);
Output for 7.2.0
Warning: count(): Parameter must be an array or an object that implements Countable in /in/tdbJ5 on line 43
Output for 5.3.19 - 7.1.10