3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { public __construct() { $this->something(); } public function something() { echo __CLASS__; // foo var_dump($this); } } class foo_bar extends foo { public __construct() { parent::something(); $this->something(); } public function something() { echo __CLASS__; // foo_bar var_dump($this); } } class foo_bar_baz extends foo_bar { public __construct() { parent::something(); $this->something(); } public function something() { echo __CLASS__; // foo_bar_baz var_dump($this); } public function call() { echo self::something(); // self echo parent::something(); // parent echo foo::something(); // grandparent } } $obj = new foo_bar_baz();
Output for 5.4.0 - 5.4.14
Parse error: syntax error, unexpected '__construct' (T_STRING), expecting variable (T_VARIABLE) in /in/7bdoq on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.24
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/7bdoq on line 5
Process exited with code 255.