- Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.29
- Parse error: syntax error, unexpected '}' in /in/guOne on line 6
Process exited with code 255.
<?php
class MyArrayIter implements Iterator {
private $storage;
public function __construct(array $a) { $storage = $a }
public function current() {
return current($this->storage);
}
public function key() {
return key($this->storage);
}
public function next() {
next($this->storage);
}
public function rewind() {
reset($this->storage);
}
public function valid() {
return key($this->storage) !== null;
}
}
$i = 1;
$a = [1,2,$i,4,5];
$iter = new MyArrayIter($a);
foreach($iter as &$v) {
$v = 1;
}
var_dump($a);
var_dump($iter);