note 40216 deleted from language.oop by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 14:49:08 +0000 |
| Subject: | note 40216 deleted from language.oop by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72436@lists.php.net to get a copy of this message | ||
Note Submitter: orion@orionrobots.co.uk
----
When using classes - it is considered better practice to access things through accessor functions
anyway.
So to get and set a static:
class fooclass
{
function &staticvar()
{
static $staticvar;
return $staticvar;
}
function SetVar($newvalue)
{
$svar = & $this->staticvar();
$svar = $newvalue;
}
function GetVar()
{
$svar = & $this->staticvar();
return $svar;
}
}
With this - although you are still needing helper variables - it is all still neatly wrapped away in
a class.
A user need not think about it - and by using only get and set accessors- if it changes, other code
will still work(one major point in Object Oriented code).