3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class values implements IteratorAggregate { private $_data = null; // array or object private $_keys = array(); private $_key = false; public function __construct($data = null){ $this->_data = $data; } public function getIterator(){ $data = $this->_data; return function() use $data{ foreach ($data as $k => $v){ yield $k => $v; } } } } $values = new values(new DateTime()); for ($i = 0; $i < 100; $i++){ foreach($values as $k => $v) { var_dump($k, $v); } }
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected '$data' (T_VARIABLE), expecting '(' in /in/6hmFW on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /in/6hmFW on line 13
Process exited with code 255.