note 40216 added to language.oop

From: Date: Wed, 25 Feb 2004 16:55:22 +0000
Subject: note 40216 added to language.oop
Groups: php.notes 
Request: Send a blank email to php-notes+get-65739@lists.php.net to get a copy of this message
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). ---- Manual Page -- http://www.php.net/manual/en/language.oop.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40216 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40216&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40216&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65739) next »