3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyValue { private $value; function get() { return $this->value; } function set($value) { $this->value = $value; } function delete() { $this->value = null; } } class MyIterator implements Iterator { private $data; private $key = 0; function __construct() { $this->data = new MyValue(); } function __destruct() { $this->data->delete(); } function current() { $this->data->set($this->key); return $this->data; } function key() { return $this->key; } function next() { ++$this->key; } function rewind() { $this->key = 0; } function valid() { return $this->key < 10; } } function iterate() { $out = array(); $values = new MyIterator(); foreach ($values as $value) { $out[] = $value; } print_r($out); return $out; } $values = iterate(); print_r($values);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MyIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/aXaT1 on line 31 Deprecated: Return type of MyIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/aXaT1 on line 40 Deprecated: Return type of MyIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/aXaT1 on line 36 Deprecated: Return type of MyIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/aXaT1 on line 48 Deprecated: Return type of MyIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/aXaT1 on line 44 Array ( [0] => MyValue Object ( [value:MyValue:private] => 9 ) [1] => MyValue Object ( [value:MyValue:private] => 9 ) [2] => MyValue Object ( [value:MyValue:private] => 9 ) [3] => MyValue Object ( [value:MyValue:private] => 9 ) [4] => MyValue Object ( [value:MyValue:private] => 9 ) [5] => MyValue Object ( [value:MyValue:private] => 9 ) [6] => MyValue Object ( [value:MyValue:private] => 9 ) [7] => MyValue Object ( [value:MyValue:private] => 9 ) [8] => MyValue Object ( [value:MyValue:private] => 9 ) [9] => MyValue Object ( [value:MyValue:private] => 9 ) ) Array ( [0] => MyValue Object ( [value:MyValue:private] => ) [1] => MyValue Object ( [value:MyValue:private] => ) [2] => MyValue Object ( [value:MyValue:private] => ) [3] => MyValue Object ( [value:MyValue:private] => ) [4] => MyValue Object ( [value:MyValue:private] => ) [5] => MyValue Object ( [value:MyValue:private] => ) [6] => MyValue Object ( [value:MyValue:private] => ) [7] => MyValue Object ( [value:MyValue:private] => ) [8] => MyValue Object ( [value:MyValue:private] => ) [9] => MyValue Object ( [value:MyValue:private] => ) )

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:
45.22 ms | 409 KiB | 8 Q