3v4l.org

run code in 300+ PHP versions simultaneously
<? 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";
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
<? 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";
Output for 8.0.13
News:keywords News:description POST:title News:keywords Fatal error: Uncaught Error: Call to private method News::getTitle() from global scope in /in/rqeDA:53 Stack trace: #0 {main} thrown in /in/rqeDA on line 53
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.6, 7.3.32 - 7.3.33, 7.4.33
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.5.24 - 5.5.35, 5.6.8 - 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.

preferences:
175.34 ms | 402 KiB | 185 Q