Skip to Content
PHPCODE
Method Chaining
laravel code / August 12, 2018

<?php

class ABC {
public $value=’$value property of ABC Class’;
}
class XYZ {
public $abc;
public function __construct()
{
$this->abc=new ABC;
}

}
$xyz=new XYZ;
//var_dump($xyz);
echo $xyz->abc->value;
?>

<?php
class ABC {
public function fun1()
{
echo “fun1 of ABC Class”;
return $this;
}
public function fun2()
{
echo “fun2 of ABC Class”;
return $this;
}
public function fun3()
{
echo “fun3 of ABC Class”;
return $this;
}
}
$abc=new ABC;
$abc->fun1()->fun2()->fun3();
?>

PHPCODE © 2024