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();

preferences:
40.54 ms | 1296 KiB | 5 Q