3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface StrategyInterface { public function run(); } class Strategy implements StrategyInterface { protected ?string $value = null; private static $counter = 0; public function __construct(private Closure $closure) { echo "Strategy Counter: ", ++self::$counter, PHP_EOL; $this->value = (string)rand(1, 100); } public function run() { $this->closure->call($this); } public function __destruct() { echo "Strategy Counter: ", --self::$counter, PHP_EOL; } } $strategy1 = new Strategy(function () { var_dump($this->value); }); $strategy2 = new Strategy(function () { var_dump($this->value); }); $strategy3 = new Strategy(function () { var_dump($this->value); }); $strategy1->run(); $strategy1 = null; $strategy2->run(); unset($strategy2); $strategy3->run(); $strategy4 = new Strategy(function () { var_dump($this->value); });
Output for git.master
Strategy Counter: 1 Strategy Counter: 2 Strategy Counter: 3 string(2) "81" Strategy Counter: 2 string(2) "57" Strategy Counter: 1 string(2) "37" Strategy Counter: 2 Strategy Counter: 1 Strategy Counter: 0
Output for git.master_jit
Strategy Counter: 1 Strategy Counter: 2 Strategy Counter: 3 string(2) "21" Strategy Counter: 2 string(2) "87" Strategy Counter: 1 string(2) "44" Strategy Counter: 2 Strategy Counter: 1 Strategy Counter: 0
Output for rfc.property-hooks
Strategy Counter: 1 Strategy Counter: 2 Strategy Counter: 3 string(2) "85" Strategy Counter: 2 string(2) "85" Strategy Counter: 1 string(2) "85" Strategy Counter: 2 Strategy Counter: 1 Strategy Counter: 0

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:
36.58 ms | 408 KiB | 5 Q