3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $prop; function setStr(string $x) { $this->prop = $x; } function setStrRef(string &$x) { $this->prop = &$x; } function setArray(array $arr) { $this->prop = $arr; } } $foo = new Foo(); $foo->setStr('abc'); var_dump($foo->prop); // "abc" $str = 'def'; // $str is a string $foo->setStrRef($str); var_dump($foo->prop); // "def" $arr = []; $foo->setArray($arr); var_dump($foo->prop); // [] var_dump($str); // [] - surprise! $str is now an array
Output for git.master, git.master_jit, rfc.property-hooks
string(3) "abc" string(3) "def" array(0) { } array(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:
35.85 ms | 401 KiB | 8 Q