3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { function __construct($id, $gen) { $this->id = $id; $this->gen = $gen; } function __destruct() { echo "__destruct $this->id\n"; var_dump($this->gen->current()); var_dump($this->gen->key()); echo "\n\n"; } } function gen() { $self = yield (0); echo "After yield 0\n"; yield new X('key', $self) => new X('value', $self); echo "After yield X\n"; yield 12; } $a = gen(); $a->next(); var_dump($a->current()); $a->send($a); var_dump($a->current()); $a->next();
Output for git.master, git.master_jit, rfc.property-hooks
After yield 0 Deprecated: Creation of dynamic property X::$id is deprecated in /in/kFjqt on line 4 Deprecated: Creation of dynamic property X::$gen is deprecated in /in/kFjqt on line 4 Deprecated: Creation of dynamic property X::$id is deprecated in /in/kFjqt on line 4 Deprecated: Creation of dynamic property X::$gen is deprecated in /in/kFjqt on line 4 object(X)#3 (2) { ["id"]=> string(5) "value" ["gen"]=> NULL } After yield X __destruct value __destruct key Fatal error: Uncaught Error: Call to a member function current() on null in /in/kFjqt:7 Stack trace: #0 /in/kFjqt(18): X->__destruct() #1 [internal function]: gen() #2 /in/kFjqt(24): Generator->send(Object(Generator)) #3 {main} Next Error: Call to a member function current() on null in /in/kFjqt:7 Stack trace: #0 /in/kFjqt(18): X->__destruct() #1 [internal function]: gen() #2 /in/kFjqt(24): Generator->send(Object(Generator)) #3 {main} thrown in /in/kFjqt on line 7
Process exited with code 255.

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