Re: static variables inside static methods

From: Date: Wed, 06 Jul 2011 22:06:45 +0000
Subject: Re: static variables inside static methods
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-313976@lists.php.net to get a copy of this message
2011/7/6 Дмитрий Степанов <dmitrij@stepanov.lv> > PHP documentation of static keywords does not unambiguously explain > behavior > of "static" variables inside methods in example #1. I believe that in > example #1 the exactly same instance of function (method) is used > irregarding of how you call it (X::test() or Y::test()), therefore I would > expect the same "static" var to be involved in both calls to test(). > I would also expect a static local variable to be tied to the function that defines it without regard to how you call it should the function happen to be static. To me, a static local variable should act like a private global variable and have exactly one value visible only to its declaring function. David

« previous php.general (#313976) next »