验证中...
Languages: PHP
Categories: 其他
Latest update 2019-01-19 08:01
gistfile1.txt
Raw Copy
class MyIterator implements Iterator {
private $position = 0;
private $arr = [
'first', 'second', 'third',
];
public function __construct() {
$this->position = 0;
}
public function rewind() {
var_dump(__METHOD__);
$this->position = 0;
}
public function current() {
var_dump(__METHOD__);
return $this->arr[$this->position];
}
public function key() {
var_dump(__METHOD__);
return $this->position;
}
public function next() {
var_dump(__METHOD__);
++$this->position;
}
public function valid() {
var_dump(__METHOD__);
return isset($this->arr[$this->position]);
}
}
$it = new MyIterator();
foreach($it as $key => $value) {
echo "\n";
var_dump($key, $value);
}

Help Search

183227_9af5e6a8_1826025 111910_4d91f001_1826025