count(): parameter must be an array or an object that implements countable (view: )
1. Error: count(): parameter must be an array or an object that implements countable (view: ). as shown in Figure 1
2. Check the code implementation
count($user->address_book);
3. Print $user->address_book, its value is null
4. Adjust the code implementation, when $user->address_book is null, the expression $user->address_book ??[]equivalent to[], otherwise it is $user->address_book.
count($user->address_book ?? []);
5. In PHP 7.2.0, when the value parameter is passed into the invalid countable type, count() will now generate a warning. The version of the environment where the error occurred is PHP 7.4.26
