Re: static
| From: | Xtlan | Date: | Thu, 03 Mar 2005 08:48:34 +0000 |
| Subject: | Re: static | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25711@lists.php.net to get a copy of this message | ||
class foo {
static public $a = 1;
public function __construct() {
echo $this->a; /* does not work */
echo foo::$a; /* work */
}
}
>Can someone please explain to me why I have to call $a outside the class
>to get the value?
I guess, it works like that because there is static declaration of
variable - which means above class allows to make only one instance of
variable - so you may refer to variable through class instance (only one
instance in memory) and you may not refer to variable through object
instances (multiple instances).
Bests.,
Xtlan.