run code in 200+ php & hhvm versions
Bugs & Features
<?php class StaticA { public function setEmail($redirect) { $this->email = $redirect; } protected function returnthis(){ return $this; } public function dosomething(){ echo "Unrspr├╝ngliche Methode"; // $obj = parent::returnthis(); //echo $obj->email; } public function classInfo(){ echo get_class(new self). "\n"; echo $this->email. "\n"; } } class StaticB extends StaticA { public function test(){ //parent::classInfo(); } public function doit(){ parent::dosomething(); } private function dosomething(){ $obj = parent::returnthis(); echo "Neue Methode!". "\n"; echo "Hier ist die E-Mail aus der Elternklasse heraus: ".$obj->email; } } $object = new StaticB(); $object->setEmail("erno@01art.de"); $object->doit();
Output for 5.3.0 - 5.4.27
Fatal error: Access level to StaticB::dosomething() must be public (as in class StaticA) in /in/41XZV on line 43
Process exited with code 255.