3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface StrategyInterface { public function run(); } class Strategy implements StrategyInterface { protected ?string $value = null; public function __construct(private Closure $closure) { $this->value = (string) rand(1, 100); } public function run() { $this->closure->call($this); } } for ($i = 0; $i < 10; $i++) { $strategy = new Strategy(function() { var_dump($this->value); }); $strategy->run(); }
Output for git.master
string(2) "43" string(2) "38" string(2) "80" string(2) "56" string(2) "27" string(2) "51" string(2) "62" string(2) "63" string(2) "62" string(2) "55"
Output for git.master_jit
string(2) "36" string(2) "26" string(2) "77" string(3) "100" string(2) "23" string(2) "71" string(2) "97" string(2) "11" string(2) "54" string(1) "2"
Output for rfc.property-hooks
string(2) "83" string(2) "54" string(2) "64" string(1) "8" string(2) "31" string(2) "53" string(2) "80" string(2) "90" string(2) "58" string(2) "21"

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