0

How does this work:

$a = $this->A()->B();

In php? Can i get an example to understand this? Or any docs or sources to understand this. Which of the function will be called first and why?

And is method chaining possible only for methods in same class?

Ravinder Baid
  • 395
  • 1
  • 15

1 Answers1

1

Below code first call function A after that call function B.

$a = $this->A()->B();

It is known as PHP Method chaining.

Also you can take reference Here.

Community
  • 1
  • 1
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122