Re: Static variable in a class method

From: Date: Thu, 14 Feb 2008 16:22:06 +0000
Subject: Re: Static variable in a class method
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-269300@lists.php.net to get a copy of this message
Nathan Nobbe schreef:
On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas <jochem@iamjochem.com> wrote:
Nathan Nobbe schreef:
what you are using is potentially not what you think it is. you are
using
a 'static variable' which is not a static class member.
actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different.
you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in
classes,
or objects.
behaviour is indentical to usage inside standalone functions.
thats a gamble since there is no description of how the static keyword behaves inside class member functions. i for one will stick to static class variables and instance variables, and avoid this static variable feature altogether.
they work the same because they are the same thing. no gamble. nada.
-nathan


« previous php.general (#269300) next »