Hi dev guys,

I'm having a bit of difficulty understanding the
behaviour of the new static variables functionality in
PHP5. I wrote this test:

<?PHP

class Foo
{
        static $i = 0;
        
        public function __construct() 
        {
                Foo::increment();
                print "instances created: " .
Foo::getInstanceCount();
        }
        
        private static function increment()
        {
                Foo::$i++;
        }

        private static function getInstanceCount()
        {
                return Foo::$i;
        }

}

$foo = new Foo();

?>

To my surprise, the count does not increment on each
page load. Obviously this means that there is no
equivalent to the classloader concept. So the classes
are loaded and unloaded on each page request. Is this
really the desired direction? I can't see what the
usefulness of this feature is if it only applies to a
single page. (Not to mention the overhead of reloading
the individual PHP files that contain my classes on
each page.)

Anyway, I'm interested in your thoughts about the
direction of PHP with regard to OOP, and to see if
there is anything I might be able to contribute.

Thanks,
Dave

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to