Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi all, here is the code I am having problem with:Code: Select all
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();From what I see, the __get() accessor function is triggerred only from OUTSIDE the class.
Now, I realise that $_id is declared as private. But in order for __get() or __set() to fire up, member either should not be declared at all, or declared as private. In any case, shouldn't private members move over to extending class? They aren't accessible from outside, but should be readable by all methods of extending class. Or am I wrong there?
I have PHP Version 5.1.6, installed on Win32 (unfortunately).
Thank you in advance,
Temuri
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]