3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataContainer implements IteratorAggregate { protected $data; public function __construct(array $data) { $this->data = $data; } public function getIterator() { foreach (array_keys($this->data) as $key) { yield $key => $data[$key]; } } } $dataContainer = new DataContainer([1, 2, 3]); foreach ($dataContainer as $value) { $value *= -1; } var_dump($dataContainer);
Output for git.master, git.master_jit
Deprecated: Return type of DataContainer::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/EEii4 on line 10 Warning: Undefined variable $data in /in/EEii4 on line 12 Warning: Trying to access array offset on value of type null in /in/EEii4 on line 12 Warning: Undefined variable $data in /in/EEii4 on line 12 Warning: Trying to access array offset on value of type null in /in/EEii4 on line 12 Warning: Undefined variable $data in /in/EEii4 on line 12 Warning: Trying to access array offset on value of type null in /in/EEii4 on line 12 object(DataContainer)#1 (1) { ["data":protected]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } }
Output for rfc.property-hooks
Deprecated: Return type of DataContainer::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/EEii4 on line 10 Warning: Undefined variable $data in /in/EEii4 on line 12 Warning: Trying to access array offset on null in /in/EEii4 on line 12 Warning: Undefined variable $data in /in/EEii4 on line 12 Warning: Trying to access array offset on null in /in/EEii4 on line 12 Warning: Undefined variable $data in /in/EEii4 on line 12 Warning: Trying to access array offset on null in /in/EEii4 on line 12 object(DataContainer)#1 (1) { ["data":protected]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } }

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:
36.44 ms | 402 KiB | 8 Q