OOP. static property in method scope?
Posted: Fri Nov 03, 2006 3:24 am
Hi...I think that was possible to do but not sure.
What I want is to decrease the load on a method.
Mehtod is used to create an array or whatever after heavy computation.
I want to do something like.
I get undeclared static property....of course I could move this static $returnValue = ''; to the class declaration and it will work...but really need this only for this one method. is it possible?
Thanks
What I want is to decrease the load on a method.
Mehtod is used to create an array or whatever after heavy computation.
I want to do something like.
Code: Select all
class myclass
{
public function methodname()
{
static $returnValue = '';
if (!empty(self::$returnValue)) {
return self::$returnValue;
}
//heavy computation here assigning self::$returnValue
return self::$returnValue;
}
}
$n = new myclass();
echo $n->methodname();Thanks