How to build multi oop functions in PHP5
问题 I have a question about OOP in PHP5. I have seen more and more code written like this: $object->function()->first(array('str','str','str'))->second(array(1,2,3,4,5)); But I don't know how to create this method. I hope somebody can help me here, :0) thanks a lot. 回答1: The key to chaining methods like that within your own classes is to return an object (almost always $this ), which then gets used as the object for the next method call. Like so: class example { public function a_function() {