3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Iterator { protected $count = 500; public function next() { $this->count--; } public function valid() { return $this->count > 0; } public function rewind() { $this->count = 500; } public function key() { return null; } public function current() { return $this->count; } } // This one $f = new Foo; foreach($f as $val) { } var_dump($f);

preferences:
37.79 ms | 402 KiB | 5 Q