RE: [PHP-NOTES] note 24883 added to keyword.extends
| From: | António Afonso dos Santos Martins | Date: | Thu, 05 Sep 2002 08:35:09 +0000 |
| Subject: | RE: [PHP-NOTES] note 24883 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36151@lists.php.net to get a copy of this message | ||
>This is the de expected behaviour when you are
>overriding a parent's member variable or method. And
>BTW, it is the inherited changeId() method in B the
>one you are calling.
i'm sorry, you're right, a more suitable example would be:
class A
{
var $id;
function changeid()
{
$this->id = 0;
}
}
class B extends A
{
var $id;
function B()
{
$this->id = 1;
}
function changeid()
{
parent::changeid();
}
}
$b = new B();
echo "B.id = $b->id <br>";
$b->changeid();
echo "B.id = $b->id";
>You might be confusing PHP w/ an OOP language like
>Java, where classes can define private, protected,
>etc. vars.
yes, i was, but isn't this then, a good motive to add a note in the extension page so no one
gets confused like me in the future?
i noticed later that someone reported this as a bug "http://bugs.php.net/bug.php?id=18024"
António Afonso