3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar implements Iterator { protected $offset = 0; function key(){ throw new Exception("collection doesn't have a key"); } function rewind(){ $this->offset = 0; } function next(){ $this->offset++; } function current(){ return "thank u baby jesus"; } function valid(){ return $this->offset <= 5; } } foreach(new Bar as $value){ var_dump($value); }

preferences:
104.55 ms | 2846 KiB | 5 Q