Hello.
First, the ...static function... has to be inside a class, otherwise you got a syntax error. Second you do not have $properties initialized. And finally it is far better to put the ...static $properties... as a static property of the class. Assuming my guess for your code functionality is correct, it should look like this if you want it as a function:
function &getStaticProperty($class, $var) {
static $properties = array();
if (!isset($properties[$class])) {
$properties[$class] = array();
}
if (!array_key_exists($var, $properties[$class])) {
$properties[$class][$var] = null;
}
return $properties[$class][$var];
}
|
or like this if you want it as a class:
class YourClassName {
static protected $properties = array();
static public function &getStaticProperty($class, $var) {
if (!isset(self::$properties[$class])) {
self::$properties[$class] = array();
}
if (!array_key_exists($var, self::$properties[$class])) {
self::$properties[$class][$var] = null;
}
return self::$properties[$class][$var];
}
}
|