Method Chaining

 <?php

class Abc
{
    public function first()
    {
        echo "This is First Function" . "<br>";
        return $this;
    }
    public function second()
    {
        echo "This is Second Function" . "<br>";
        return $this;
    }
    public function third()
    {
        echo "This is Third Function" . "<br>";
        return $this;
    }
}
$test = new Abc();
$test->first()->second()->third();

//  OUTPUT:
//This is First Function
// This is Second Function
// This is Third Function
?>

Comments

Popular posts from this blog

Logical_Operators

SubQuery with EXISTS and NOT EXISTS in PHP

Get Functions