3v4l.org

run code in 300+ PHP versions simultaneously
<?php class hello { public $props = array(); function __construct() { $this->props = ['hello' => 5, 'props' => ['keyme' => ['test' => 5]]]; } } $data = new hello(); $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data), RecursiveIteratorIterator::SELF_FIRST); echo "Expect to see all keys in ->props here: \n"; foreach($iterator as $k=>$v) { echo $k . "\n"; } echo "Reimplemented RecursiveArrayIterator from source code here: http://fossies.org/dox/php-7.0.11-src/recursivearrayiterator_8inc_source.html \n"; class RecursiveArray extends ArrayIterator implements RecursiveIterator { function hasChildren() { return is_array($this->current()); } function getChildren() { if ($this->current() instanceof self) { return $this->current(); } if (empty($this->ref)) { $this->ref = new ReflectionClass($this); } return $this->ref->newInstance($this->current()); } private $ref; } $iterator = new RecursiveIteratorIterator(new RecursiveArray($data), RecursiveIteratorIterator::SELF_FIRST); echo "Expect to see all keys in ->props here: \n"; foreach($iterator as $k=>$v) { echo $k . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Expect to see all keys in ->props here: props hello props keyme test Reimplemented RecursiveArrayIterator from source code here: http://fossies.org/dox/php-7.0.11-src/recursivearrayiterator_8inc_source.html Deprecated: Return type of RecursiveArray::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/DO2SA on line 26 Deprecated: Return type of RecursiveArray::getChildren() should either be compatible with RecursiveIterator::getChildren(): ?RecursiveIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/DO2SA on line 31 Expect to see all keys in ->props here: props hello props keyme test

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:
77.19 ms | 403 KiB | 8 Q