- print_r: documentation ( source)
<?php
class User {};
class UserList
{
private $list = [];
public function __construct(User ...$user)
{
$this->list = $user;
}
public function add(User $user)
{
$this->list[] = $user;
}
public function all(): array
{
return $this->list;
}
}
//
// Usage
//
$userList = new UserList(new User(), new User());
$userList->add(new User());
print_r($userList->all());