How to call function lmn()
without touching class B
from class A
class A extends B{
public function abc(){
return "abc";
}
...
}
class B{
public function xyz(){
return "xyz";
}
...
}
class C{
protected function lmn(){
return "lmn";
}
...
}
please guide me for this
You cannot call it since protected means to be a function that can be called from the child classes.
In your case, you need to make an instance of B to call lmn in whatever class.
You can make some kind of proxy class that extends from C and provides a public method for access:
class ProcyForC extends C {
public function getLmn() {
return $this->lmn();
}
}
echo (new ProxyForC())->getLmn();