3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyIterator implements Iterator { public $var = array(); public function print_r($var); public function __construct($arra) { if (is_array($arra)) { $this->var = $arra; echo implode(',',$arra) ;} } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $key = key($this->var); $var = ($key !== NULL && $key !== FALSE); echo "valid: $var\n"; return $var; } } $values = array(1,2,3); $it = new MyIterator($values); foreach ($it as $a => $b) { print "$a: $b\n"; } ?>
Output for 5.3.0 - 5.4.19
Fatal error: Non-abstract method MyIterator::print_r() must contain body in /in/tUGhK on line 5
Process exited with code 255.