Static variable in a class method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a class method which declares a static variable within.However, 
across all the instances of the class, the current value on that variable 
replicates. Is it the intended functionality? Example: class A {    public 
function foo() {        static $i=0;        $i++;    }}$obj1 = new 
A();$obj1->foo(); //$i = 1 $obj2 = new A();$obj2->foo(); //$i = 2 where I 
think it should be 1, becaue it's a new instance. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux