3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $data = [1,2,3,4,5]; public function __construct() { next($this->data); } public function getIter() { foreach ($this->data as $key => $value) { yield $key => $value; } } } $a = new A; $gen = $a->getIter(); var_dump(current($a->data)); foreach ($gen as $key => $value) { var_dump($value); } var_dump(current($a->data));
Output for git.master, git.master_jit, rfc.property-hooks
int(2) int(1) int(2) int(3) int(4) int(5) int(2)

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:
43.93 ms | 2111 KiB | 4 Q