3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class IncrementIterator implements iterator { protected $start; protected $end; protected $current; public function __construct($start, $end) { $this->start = $start; $this->end = $end; } public function rewind() { $this->current = $this->start; } public function valid() { return $this->current <= $this->end; } public function key() { return $this->current; } public function current() { return $this->current; } public function next() { $this->current++; } } $aIterator = new IncrementIterator(0, 26); $bIterator = new IncrementIterator(0, 26); $cIterator = new IncrementIterator(0, 26); $dIterator = new IncrementIterator(0, 26); $multipleIterator = new MultipleIterator(); $multipleIterator->attach($aIterator); $multipleIterator->attach($bIterator); $multipleIterator->attach($cIterator); $multipleIterator->attach($dIterator); foreach ($multipleIterator as $current) { var_dump($current); }
based on MCjOP
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined method MultipleIterator::attach() in /in/FnWPo:39 Stack trace: #0 {main} thrown in /in/FnWPo on line 39
Process exited with code 255.
Output for 5.3.0 - 5.6.28, hhvm-3.12.0
Fatal error: Call to undefined method MultipleIterator::attach() in /in/FnWPo on line 39
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.2.17
Fatal error: Class 'MultipleIterator' not found in /in/FnWPo on line 38
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/FnWPo 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/FnWPo on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/FnWPo on line 2
Process exited with code 255.