Re: __get() accessor question (a bug maybe?)
| From: | TemuriI | Date: | Wed, 15 Nov 2006 16:12:57 +0000 |
| Subject: | Re: __get() accessor question (a bug maybe?) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244672@lists.php.net to get a copy of this message | ||
Hi, thanks for the response.
But the thing with __get() & _set() is that the members should either be *not* declared or be of private type to trigger accessor functions. That's the reason I have _id as private (also to trigger some other action when __set() fires up).
Now, it gets inherited by class inputText so I'd expect accessors work just the same in a class that extends any base class.
Or am I wrong there?
Thx,
Temuri
Barry wrote:
TemuriI schrieb:Hi all, here is the code I am having problem with: ============================================ class baseForm { private $_id = 10; function __get($member) {Probably bcause its private and therefore only for that class?echo "Accessing member \"{$member}\" : <br />\n"; return $this->$member;} function checkID() {echo $this->_id."<br />\n";} } class inputText extends baseForm { function display() {$this->checkID(); echo $this->_id."<br />\n";} } $f = new inputText(); echo $f -> display(); ============================================