__get() accessor question (a bug maybe?)

From: Date: Wed, 15 Nov 2006 15:22:16 +0000
Subject: __get() accessor question (a bug maybe?)
Groups: php.general 
Request: Send a blank email to php-general+get-244669@lists.php.net to get a copy of this message
Hi all, here is the code I am having problem with: ============================================ class baseForm { private $_id = 10; function __get($member) {
       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(); ============================================ The question is: why the string 'Accessing member "_id" :' is only displayed once? If you look at the code - it actually accesses $_id member TWICE. But __get() gets gets triggered only once. WHY?!! From what I see, the __get() accessor function is triggerred only from OUTSIDE the class. PHP Version 5.1.6, installed on Win32 (unfortunately). Thank you in advance, Temuri

« previous php.general (#244669) next »