How to call a function lmn() without touching a class B from within a classA
lmn()
B
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 call me for this
You can create some kind of proxy class that extends from C and provides a public accessor:
class ProcyForC extends C { public function getLmn() { return $this->lmn(); } } echo (new ProxyForC())->getLmn();
You cannot call it as protected means a function that can be called from child classes.
In your case, you need to make an instance of B to call lmn in any class.