Re: how to count objects instances
| From: | tyler at carbon dot homelinux dot com | Date: | Tue, 24 Aug 2004 14:21:37 +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-194576@lists.php.net to get a copy of this message | ||
Thanks,
But im using php 4.3.
Quoting Curt Zirzow <php-general@zirzow.dyndns.org>:
> * Thus wrote Robert Cummings:
> > On Mon, 2004-08-23 at 20:54, John Holmes wrote:
> > > 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--;
> > }
>
> And:
> function __clone()
> {
> Foo::$instances++;
> }
>
>
> Curt
> --
> First, let me assure you that this is not one of those shady pyramid schemes
> you've been hearing about. No, sir. Our model is the trapezoid!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
----------------------------------------------------------------------
This mail sent through Horde-Toaster (http://qmailtoaster.clikka.com/)