I’m trying to improve my OOP skill. Recently, I’ve read an article that has this code structure:
$this->getUserInfo()->display();
When I code, I just do something like this:
$this->getUserInfo();
How do I do something like the above…”multiple-passing” or whatever it’s called. I think it’s cool if I can make my code be able to do that…just looking at the code…I’m impressed.
Can somebody post a code something replicating the above…I want to try it too. I want to learn how^^
Thanks!
The trick is to simply return an object from the
getUserInfo()method, often the method returns the object it belongs to, i.e.$this.