Classes implementing Countable can be used with the count() function
class MyClass implements Countable {
    public function count() {
        return 5;
    }
}
$c = new MyClass();
echo $c->count();
echo count($c); //calls $c->count();
We can use count() function for the class instance, when the class implements
Countable
interface
by Valeri Tandilashvili
4 years ago
PHP
OOP
PHP Object Oriented Programming (OOP)
2
Pro tip: use ```triple backticks around text``` to write in code fences