3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class DebugRAI extends RecursiveArrayIterator { public function rewind() { echo __METHOD__, "\n"; return parent::rewind(); } public function current() { echo __METHOD__, "\n"; return parent::current(); } public function key() { echo __METHOD__, "\n"; return parent::key(); } public function valid() { echo __METHOD__, "\n"; return parent::valid(); } public function next() { echo __METHOD__, "\n"; return parent::next(); } } $array = array("A", "B", "C"); $iterator = new RecursiveIteratorIterator(new DebugRAI($array)); while ($iterator->valid()) { echo $iterator->current(), "\n"; $iterator->next(); }
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
DebugRAI::valid DebugRAI::current A DebugRAI::valid DebugRAI::valid A DebugRAI::next DebugRAI::valid DebugRAI::valid DebugRAI::current B DebugRAI::next DebugRAI::valid DebugRAI::valid DebugRAI::current C DebugRAI::next DebugRAI::valid DebugRAI::valid
Output for hhvm-3.10.0 - 3.12.0
DebugRAI::valid DebugRAI::current A DebugRAI::valid DebugRAI::current DebugRAI::current DebugRAI::valid DebugRAI::current A DebugRAI::next DebugRAI::valid DebugRAI::current DebugRAI::current DebugRAI::valid DebugRAI::current B DebugRAI::next DebugRAI::valid DebugRAI::current DebugRAI::current DebugRAI::valid DebugRAI::current C DebugRAI::next DebugRAI::valid DebugRAI::valid
Output for 5.0.0 - 5.0.5
Fatal error: Class 'RecursiveArrayIterator' not found in /in/DmAHB on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/DmAHB on line 4
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 T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/DmAHB on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/DmAHB on line 4
Process exited with code 255.