Re: Static class variables and $this
| From: | Andi Gutmans | Date: | Thu, 12 Feb 2004 20:31:34 +0000 |
| Subject: | Re: Static class variables and $this | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7788@lists.php.net to get a copy of this message | ||
Use self::$cnt but internals@ is not meant for PHP questions but for discussing development of PHP.
Andi
At 07:48 PM 2/12/2004 +0000, zhundiak@comcast.net wrote:
Can someone point me to some more information on using PHP 5's static class variables? All I have been able to find is the zend php5 changes page. Consider: error_reporting(E_ALL | E_STRICT); class foo { static $cnt = 0; function getCnt1() { return $this->cnt; } // Does not work, undefined variable function getCnt2() { return foo:$cnt; } // Works as expected } $obj = new foo(); echo $obj->getCnt1(); It seems that I should be able to access static class variables from inside of created objects using $this. Tested with php5b3. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php