3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class EmptyIterator extends Iterator implements Countable { /** No operation. * @return void */ function rewind() { // nothing to do } /** @return \c false */ function valid() { return false; } /** This function must not be called. It throws an exception upon access. * @throw Exception * @return void */ function current() { throw new Exception('Accessing the value of an EmptyIterator'); } /** This function must not be called. It throws an exception upon access. * @throw Exception * @return void */ function key() { throw new Exception('Accessing the key of an EmptyIterator'); } /** No operation. * @return void */ function next() { // nothing to do } /** * @return int */ function count() { return 0; } } $ei = new EmptyIterator; echo count($ei);
Output for 7.0.0 - 7.1.0
Fatal error: Cannot declare class EmptyIterator, because the name is already in use in /in/VDOpJ on line 2
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: Class already declared: EmptyIterator in /in/VDOpJ on line 2
Process exited with code 255.
Output for 5.0.2 - 5.6.28
Fatal error: Class EmptyIterator cannot extend from interface Iterator in /in/VDOpJ on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Fatal error: Class EmptyIterator must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/VDOpJ on line 2
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/VDOpJ on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/VDOpJ on line 2
Process exited with code 255.