3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $_locations = array(); public $test = array(); private $_test = array(); public function getResult() { var_dump($this->_locations = true); // works var_dump($this->_locations = "test"); // works var_dump($this->_locations = array()); // works var_dump($this->_locations = array("test")); // produces a critical error var_dump($this->_locations = array("test" => "test")); // produces a critical error var_dump($this->_locations[] = "test"); // produces a critical error var_dump($this->_locations["test"] = "test"); // produces a critical error var_dump($test = array("test" => "test")); // works var_dump($this->test = array()); // works var_dump($this->test = array("test")); // works var_dump($this->_test = array()); // works var_dump($this->_test = array("test")); // works } } $obj = new A(); $obj->getResult();
Output for rfc.property-hooks, git.master, git.master_jit
bool(true) string(4) "test" array(0) { } array(1) { [0]=> string(4) "test" } array(1) { ["test"]=> string(4) "test" } string(4) "test" string(4) "test" array(1) { ["test"]=> string(4) "test" } array(0) { } array(1) { [0]=> string(4) "test" } array(0) { } array(1) { [0]=> string(4) "test" }

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:
41.47 ms | 1295 KiB | 4 Q