Re: how to count objects instances
| From: | Daniel Schierbeck | Date: | Tue, 24 Aug 2004 12:00:39 +0000 |
| Subject: | Re: how to count objects instances | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194565@lists.php.net to get a copy of this message | ||
Curt Zirzow wrote:
* Thus wrote Robert Cummings:By the way, use "self" instead of "Foo", just in case you change the class' name. -- Daniel SchierbeckOn Mon, 2004-08-23 at 20:54, John Holmes wrote:And:tyler@carbon.homelinux.com wrote: You could write a wrapper class for Test that kept count of the instances and returned a new object upon request...In PHP5: <?php class Foo { static $instances = 0; function __construct() {Foo::$instances++; }function __destruct() {Foo::$instances--;}function __clone() { Foo::$instances++; }Curt Ooops, didn't see your post, hehe...