3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<? class Post { public function __construct() { echo $this->getKeywords(); echo "\r\n"; echo $this->getDescription(); echo "\r\n"; echo $this->getTitle(); echo "\r\n"; } public function getKeywords() { return 'POST:keywords'; } protected function getDescription() { return 'POST:description'; } private function getTitle() { return 'POST:title'; } } class News extends Post { public function __construct() { parent::__construct(); } public function getKeywords() { return 'News:keywords'; } protected function getDescription() { return 'News:description'; } private function getTitle() { return 'News:title'; } } //1 случай $Object = new News(); //2 случай echo $Object->getKeywords(); echo "\r\n"; echo $Object->getTitle(); echo "\r\n"; echo $Object->getDescription(); echo "\r\n";
based on Mo2Zo
Output for 7.0.0 - 7.2.0
News:keywords News:description POST:title News:keywords Fatal error: Uncaught Error: Call to private method News::getTitle() from context '' in /in/rqeDA:53 Stack trace: #0 {main} thrown in /in/rqeDA on line 53
Process exited with code 255.
Output for 5.4.11 - 5.6.28
News:keywords News:description POST:title News:keywords Fatal error: Call to private method News::getTitle() from context '' in /in/rqeDA on line 53
Process exited with code 255.
Output for 5.3.21 - 5.3.29
<? class Post { public function __construct() { echo $this->getKeywords(); echo "\r\n"; echo $this->getDescription(); echo "\r\n"; echo $this->getTitle(); echo "\r\n"; } public function getKeywords() { return 'POST:keywords'; } protected function getDescription() { return 'POST:description'; } private function getTitle() { return 'POST:title'; } } class News extends Post { public function __construct() { parent::__construct(); } public function getKeywords() { return 'News:keywords'; } protected function getDescription() { return 'News:description'; } private function getTitle() { return 'News:title'; } } //1 случай $Object = new News(); //2 случай echo $Object->getKeywords(); echo "\r\n"; echo $Object->getTitle(); echo "\r\n"; echo $Object->getDescription(); echo "\r\n";