3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public $define; // null public $redefine; // null public function define(?bool $something = null): ?bool { return $this->define = $this->define ?? $something; } public function redefine(?bool $something = null): ?bool { return $this->redefine = $something ?? $this->redefine; } } $test = function(?bool $value) { var_export($value ?? 'Not set!' ?: 'False!'); echo PHP_EOL; }; $foo = new Test(); $test($foo->define()); $test($foo->define(true)); $test($foo->define()); $test($foo->define(false)); $test($foo->define()); $test($foo->redefine()); $test($foo->redefine(true)); $test($foo->redefine()); $test($foo->redefine(false)); $test($foo->redefine());
Output for git.master, git.master_jit, rfc.property-hooks
'Not set!' true true true true 'Not set!' true true 'False!' 'False!'

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.81 ms | 405 KiB | 5 Q