christophe barbe wrote: > > I guess the answer is obvious but can't find it in the manual. > > Is it possible to have a variable in a class that is shared by all > instances. I thought 'static' would do it but apparently not.
I don't recall such a thing, but if you can't find an option for a class variable, implement a method which emulates a class variable system. function getSetClassVar( $name, $set=null ) { static $values = array(); if( !is_null( $set ) ) { $values[$name] = $set; } return isset( $values[$name] ) ? $values[$name] : null; } function getClassVar( $name ) { return $this->getSetClassVar( $name ); } function setClassVar( $name, $value ) { return $this->getSetClassVar( $name ); } HTH, Rob. -- .-----------------. | Robert Cummings | :-----------------`----------------------------. | Webdeployer - Chief PHP and Java Programmer | :----------------------------------------------: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :----------------------------------------------: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `----------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php