The 5th Annual China PHP Conference

Voting

Please answer this simple SPAM challenge: three plus one?
(Example: nine)

The Note You're Voting On

pgarvin76+php dot net at NOSPAMgmail dot com
8 years ago
Method chaining is read left to right (left associative):
<?php

class Test_Method_Chain
{
    public function
One()
    {
        echo
"One" . PHP_EOL;
        return
$this;
    }

    public function
Two()
    {
        echo
"Two" . PHP_EOL;
        return
$this;
    }

    public function
Three()
    {
        echo
"Three" . PHP_EOL;
        return
$this;
    }
}

$test = new Test_Method_Chain();

$test->One()->Two()->Three();

/* Ouputs:
One
Two
Three
*/
?>

<< Back to user notes page

To Top