summaryrefslogtreecommitdiff
path: root/pear/PEAR.php
diff options
context:
space:
mode:
authorRichard Heyes <richard@php.net>2002-04-08 21:03:41 +0000
committerRichard Heyes <richard@php.net>2002-04-08 21:03:41 +0000
commitf006b2bbc3db5d32f260aacaaaf295c27f145f6b (patch)
treec3ecaa101de203b1e7638adfa3d1539d71ccd2a9 /pear/PEAR.php
parente3cc458d25a434cf21b760d245dcdebb540bd2f8 (diff)
downloadphp-git-f006b2bbc3db5d32f260aacaaaf295c27f145f6b.tar.gz
* Added getStaticProperty() for static methods.
Diffstat (limited to 'pear/PEAR.php')
-rw-r--r--pear/PEAR.php21
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()
/**