3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { protected $variable = array('test' => 'hello world!', 'another_test' => 'hello world?'); public function __construct($var) { var_dump($this->variable); // this is the whole array you defined initially $this->variable = $var; // here the $var ('testing contents') overwrites `variable` var_dump($var); // 'testing contents' var_dum($this->variable); // $this->variable is now the same as the argument passed in } } new Test('testing contents');
based on uackm
Output for 7.0.0 - 7.2.0
array(2) { ["test"]=> string(12) "hello world!" ["another_test"]=> string(12) "hello world?" } string(16) "testing contents" Fatal error: Uncaught Error: Call to undefined function var_dum() in /in/9mS8P:12 Stack trace: #0 /in/9mS8P(16): Test->__construct('testing content...') #1 {main} thrown in /in/9mS8P on line 12
Process exited with code 255.
Output for 5.3.18 - 5.6.28
array(2) { ["test"]=> string(12) "hello world!" ["another_test"]=> string(12) "hello world?" } string(16) "testing contents" Fatal error: Call to undefined function var_dum() in /in/9mS8P on line 12
Process exited with code 255.