Is there a way to find out how many times a class has been instantiated in php?

Posted by sprugman on Stack Overflow See other posts from Stack Overflow or by sprugman
Published on 2010-04-27T22:40:59Z Indexed on 2010/04/27 22:43 UTC
Read the original article Hit count: 123

Filed under:
|

I'm currently using this method:

class Foo {
    private static $num_instatnces = 0;

    function __construct() {
        self::$num_instances++;
    }
}

which seems to work, but I'm wondering if there's a built in way....

© Stack Overflow or respective owner

Related posts about php

Related posts about oop