diff options
author | Richard Heyes <richard@php.net> | 2002-04-08 21:03:41 +0000 |
---|---|---|
committer | Richard Heyes <richard@php.net> | 2002-04-08 21:03:41 +0000 |
commit | f006b2bbc3db5d32f260aacaaaf295c27f145f6b (patch) | |
tree | c3ecaa101de203b1e7638adfa3d1539d71ccd2a9 /pear/PEAR.php | |
parent | e3cc458d25a434cf21b760d245dcdebb540bd2f8 (diff) | |
download | php-git-f006b2bbc3db5d32f260aacaaaf295c27f145f6b.tar.gz |
* Added getStaticProperty() for static methods.
Diffstat (limited to 'pear/PEAR.php')
-rw-r--r-- | pear/PEAR.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pear/PEAR.php b/pear/PEAR.php index 2d4edd619c..b3ccf74fb3 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -174,6 +174,27 @@ class PEAR } // }}} + // {{{ getStaticProperty() + + /** + * If you have a class that's mostly/entirely static, and you need static + * properties, you can use this method to simulate them. Eg. in your method(s) + * do this: $myVar = &PEAR::getStaticProperty('myVar'); + * You MUST use a reference, or they will not persist! + * + * @access public + * @param string $class The calling classname, to prevent clashes + * @param string $var The variable to retrieve. + * @return mixed A reference to the variable. If not set it will be + * auto initialised to NULL. + */ + function &getStaticProperty($class, $var) + { + static $properties; + return $properties[$class][$var]; + } + + // }}} // {{{ registerShutdownFunc() /** |