__get() accessor question (a bug maybe?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux