3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class test { public $generator; public function __construct() { $this->generator = (function() { yield from [1,1,2,3,5,8,13,21]; })(); } public function getValue() { while($this->generator->valid()) { $latitude = $this->generator->current(); $this->generator->next(); return $latitude; } throw new RangeException('End of line'); } } $line = new test(); try { for($i = 0; $i < 10; ++$i) { echo $line->getValue(); echo PHP_EOL; } } catch (Exception $e) { echo $e->getMessage(); }
based on 2WAh2
Output for hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
1 1 2 3 5 8 13 21 End of line
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ',', expecting ']' in /in/Zdor7 on line 8
Process exited with code 255.