is there any possible to return a function in a multiple add new Class Object ? THanks in advance.
example :
public function model()
{
return new Users(['...' => user1, .....]);
return new Customers(['...' => customer1, .....]);
}
CodePudding user response:
You can put them in an array and return both. You can then access the object you want and process it further.
CodePudding user response:
Once the function reaches the return
statement lines/codes below, that won't get executed. If you use an Advanced IDE (PhpStorm which I use) it will show you a message saying "Unreachable...".
To archive your goal, you can pass them in an array.
public function model()
{
return [
'user' => new User(....),
'customer' => new Customers(...)
];
}