3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $val; public function __construct($val) { $this->val = $val; } } $storage = new SplObjectStorage; $storage->attach(new A(1)); $storage->attach(new A(2)); $storage->attach(new A(3)); $storage->attach(new A(4)); $storage->attach(new A(5)); $storage->attach(new A(6)); $storage->attach(new A(7)); $storage->attach(new A(8)); $storage->attach(new A(9)); $storage->attach(new A(10)); $storage->rewind(); $iterated = 0; $expected = count($storage); while ($storage->valid()) { $iterated++; $object = $storage->current(); echo 'Iteration #' .$iterated . '(Object A(' . $object->val . '))'; $storage->next(); if($iterated === 2) { echo ' - deleted Object A(' . $object->val . ') '; $storage->detach($object); continue; } echo PHP_EOL; } if(count($storage) != $expected) { echo 'Error!' . PHP_EOL; } else { echo 'Success!' . PHP_EOL; } exit;
Output for git.master, git.master_jit, rfc.property-hooks
Iteration #1(Object A(1)) Iteration #2(Object A(2)) - deleted Object A(2) Iteration #3(Object A(1)) Iteration #4(Object A(3)) Iteration #5(Object A(4)) Iteration #6(Object A(5)) Iteration #7(Object A(6)) Iteration #8(Object A(7)) Iteration #9(Object A(8)) Iteration #10(Object A(9)) Iteration #11(Object A(10)) Error!

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