简体   繁体   中英

Methods inside Methods PHP

The following code is the sample code:

$sample= $module->get('data')
            ->anotherModule
            ->find(true);

I couldn't understand what exactly is the object hierarchy in here. According to my knowledge, there must be an object $module and that class has a method get which takes the parameter as 'data' .

But according to the code, still it gets deeper to anotherModule and find method. Can anyone explain me what is happening in this code?

This is called method chaining .

A method returns an object which contains other methods. You can find an example for that here: PHP method chaining?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM