3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooNoMoreException extends Exception {} class Foo { protected $count = 500; public function step() { if (!$this->count) { throw new FooNoMoreException('No more steps to take.'); } $this->count--; } } $f = new Foo; try { while ($f->step()) {} } catch {} var_dump($f);
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.21
Parse error: syntax error, unexpected '{', expecting '(' in /in/tkvc6 on line 19
Process exited with code 255.

preferences:
180.17 ms | 1395 KiB | 57 Q