php 5.3 - why is this abstract class returning fatal Error in php -


abstract  class myabstractclass{     abstract  protected function dosomething();     function threedots(){         return  "...";     } } class myclassa extends  myabstractclass{     protected function dosomething(){         $this->threedots();     } } $myclass = new myclassa(); $myclass->dosomething(); 

this error being spitted out "fatal error: call protected method myclassa::dosomething() context in test.php on line 10 ".iam trying know reason error.

you have declared function dosomething proteced, means can used inside parent classes, child classes or itself. you're using outside of that.

you can try changing

abstract  protected function dosomething(); 

into

abstract public function dosomething(); 

and

protected function dosomething(){ 

into

public function dosomething() { 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -