3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php <?php // fr Nikita's RFC class DataContainer implements IteratorAggregate { protected $data; public function __construct(array $data) { $this->data = $data; } public function &getIterator() { foreach ($this->data as $key => &$value) { yield $key => $value; } } } $dataContainer = new DataContainer([1, 2, 3]); foreach ($dataContainer as &$value) { $value *= -1; } // $this->data is now [-1, -2, -3] foreach ($dataContainer as $value); var_dump($dataContainer);
Output for 5.3.0 - 5.4.11
Parse error: syntax error, unexpected '<' in /in/8dn1P on line 2
Process exited with code 255.