3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Tree { public $i; public $l; public $r; public function __construct($item, $depth) { $this->i = $item; if($depth) { $this->l = new Tree($item * 2 - 1, --$depth); $this->r = new Tree($item * 2, $depth); } } public function check() { return $this->i + ($this->l->l === null ? $this->l->check() : $this->l->i) - ($this->r->l === null ? $this->r->check() : $this->r->i); } } $minDepth = 4; $n = $argc == 2 ? $argv[1] : 1; $maxDepth = $minDepth + 2 > $n ? $minDepth + 2 : $n; $stretchDepth = $maxDepth + 1; $stretch = new Tree(0, $stretchDepth); printf("stretch tree of depth %d\t check: %d\n", $stretchDepth, $stretch->check()); unset($stretch); $longLivedTree = new Tree(0, $maxDepth); $iterations = 1 << $maxDepth; do { $check = 0; for($i = 1; $i <= $iterations; ++$i) { $check += (new Tree($i, $minDepth))->check() + (new Tree(-$i, $minDepth))->check(); } printf("%d\t trees of depth %d\t check: %d\n", $iterations<<1, $minDepth, $check); $minDepth += 2; $iterations >>= 2; } while($minDepth <= $maxDepth); printf("long lived tree of depth %d\t check: %d\n", $maxDepth, $longLivedTree->check());
Output for git.master, git.master_jit, rfc.property-hooks
stretch tree of depth 7 check: -1 128 trees of depth 4 check: -128 32 trees of depth 6 check: -32 long lived tree of depth 6 check: -1

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:
42.09 ms | 401 KiB | 8 Q