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
Post a Comment