Static property function

From: Date: Sat, 06 Apr 2002 18:56:03 +0000
Subject: Static property function
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-5219@lists.php.net to get a copy of this message
Since php has no static properties yet, I'd like to suggest adding this function to PEAR.php. It simply keeps a record of static variables, and negates the need to use globals to share data between functions. function &_getStaticProperty($class, $var) { static $properties; return $properties[$class][$var]; } In your static methods you would then be able to do this: $myVar = &PEAR::_getStaticProperty('myClass', 'myVar') $myVar would be a reference to the data in $properties[$class][$var] and would hence survive between calls. Not much point using it if you only have one static method, but if you have two or more and want to share data between them, it comes in handy. With some changes I'm making to the File class, this function will be added, but since it's usful cross classes, it might be an idea to add it to PEAR.php. -- Richard Heyes "If you have any trouble sounding condescending, find a Unix user to show you how it's done." - Scott Adams

« previous php.pear.dev (#5219) next »