Possible Duplicate:
PHP method chaining?
I'm relatively new to PHP and OOP, and I'm having trouble understanding a recurring structure popping up in my database code.
I understand how to create a class, instantiate it, as well as access properties and methods, but $myobject->function()
is about as complicated as it gets for me for now.
What is this structure?
$myobject->function()->something
. I am repeatedly seeing this more and more, especially as I start wrapping my head around mysql PDO queries. For example:
$query->function1($arg)
->function2($arg)
->function3($arg);
What's happening here? is it simply chaining one call of multiple methods in the class, or are those sub functions of function1()
? What would the class definition look like?