3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $name; public function __construct($name) { $this->name = $name; } } class Bar { private $foo; public function __construct(Foo $foo = null, $default = 'default') { $this->foo = $foo ?: new Foo($default); } public function getFooName() { return $this->foo->name; } } $foo = new Foo('John'); $bar = new Bar($foo); echo $bar->getFooName(), PHP_EOL; // John $bar = new Bar(); echo $bar->getFooName(), PHP_EOL; // default $bar = new Bar(null, 'something'); echo $bar->getFooName(), PHP_EOL; // something
Output for git.master_jit, git.master, rfc.property-hooks
John default something

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