<?php
class IncrementIterator implements iterator {
protected $start;
protected $end;
protected $current;
public function __construct($start, $end) {
$this->start = $start;
$this->end = $end;
}
public function rewind() {
$this->current = $this->start;
}
public function valid() {
return $this->current <= $this->end;
}
public function key() {
return $this->current;
}
public function current() {
return $this->current;
}
public function next() {
$this->current++;
}
}
$aIterator = new IncrementIterator(0, 26);
foreach ($aIterator as $a) {
echo "$a\n";
}
Deprecated: Return type of IncrementIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MCjOP on line 24
Deprecated: Return type of IncrementIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MCjOP on line 28
Deprecated: Return type of IncrementIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MCjOP on line 20
Deprecated: Return type of IncrementIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MCjOP on line 16
Deprecated: Return type of IncrementIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MCjOP on line 12
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26