3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyIterator implements Iterator { public $var = array(); public function pprrint() {echo implode(',',$this->var);} public function __construct($arra) { if (is_array($arra)) { $this->var = $arra; /* echo implode(',',$arra) ;*/} } public function rewind() { echo "rewinding\n"; reset($this->var); } public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $this->var=$var echo "valid: $var\n"; return $var; } } $values = array(1,2,3); $it = new MyIterator($values); $it->pprrint(); foreach($it as $key => $value) { print "$key => $value\n"; } echo "\n"; ?>
Output for 5.4.0 - 5.4.19
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/5LrMG on line 46
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_ECHO in /in/5LrMG on line 46
Process exited with code 255.