Re: Static variable in a class method

From: Date: Thu, 14 Feb 2008 01:44:48 +0000
Subject: Re: Static variable in a class method
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-269272@lists.php.net to get a copy of this message
--- Pauau <wakamonka747@hotmail.com> wrote: > 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. > Pauau, Please visit the link below for help.. http://www.php.net/manual/en/language.oop5.static.php --- Nirmalya Lahiri [+91-9433113536] ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs

« previous php.general (#269272) next »