Actually, it is not possible to access class methods through a variable with another method. Here there is such a class for example
class Handler { public function getHandler() { return 'some handler'; } public function getFile() { return 'some file'; } } I create an instance of the class $class = new Handler(); The getHandler method is available $handler = $class->getHandler();
And I want to access the getFile() method like this $file = $handler->getFile(); With this treatment, I get the error:
Fatal error: Uncaught Error: Call to a member function getFile () on string
Of course, such a call $file = $class->getFile(); it works, but I want it to work like this $file = $handler->getFile();