So that count($object)
will return the number of records in it
Take a look at Countable::count
class MyClass implements Countable {
public function count() {
//return count
}
}
$c = new MyClass();
count($c); //calls $c->count();
If you have Standard PHP Library installed you should be able to simply implement Countable in your class and then define the count() function:
class foo implements Countable {
...
public function count() {
# do stuff here
return $count;
}
}
Read more about the SPL here: http://www.php.net/manual/en/book.spl.php
More about the Countable interface here: http://php.net/manual/en/countable.count.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With