3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a implements \Iterator, \Countable { private $a; private $b; private $c; private $keys = [ 'a', 'b', 'c' ]; private $pointer; public function __construc($a = null, $b = null, $c = null) { $this->a = $a; $this->b = $b; $this->c = $c; } public function count() { $pointer = 0; foreach ($this as $element) { if ($element) { $pointer++; } } return $pointer; } public function current() { $key = $this->key(); var_dump($key); return $this->{$key}; } public function key() { $this->keys[$this->pointer]; } public function next() { $this->pointer++; } public function valid() { return $this->pointer < count($this->keys); } public function rewind() { $this->pointer = 0; } } $me = new a('a'); var_dump($me->count()); foreach ($me as $key => $el) { var_dump($key, $el); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of a::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/hkarD on line 37 Deprecated: Return type of a::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/hkarD on line 49 Deprecated: Return type of a::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/hkarD on line 44 Deprecated: Return type of a::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/hkarD on line 54 Deprecated: Return type of a::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/hkarD on line 59 Deprecated: Return type of a::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/hkarD on line 24 NULL Warning: Undefined property: a::$ in /in/hkarD on line 41 NULL Warning: Undefined property: a::$ in /in/hkarD on line 41 NULL Warning: Undefined property: a::$ in /in/hkarD on line 41 int(0) NULL Warning: Undefined property: a::$ in /in/hkarD on line 41 NULL NULL NULL Warning: Undefined property: a::$ in /in/hkarD on line 41 NULL NULL NULL Warning: Undefined property: a::$ in /in/hkarD on line 41 NULL NULL

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52 ms | 405 KiB | 8 Q