I have a question about the way in which the output is displayed.
<?php
class Base
{
private $privattrib = "Private Attribute1";
function GetAttrib()
{
echo $this->privattrib;
}
}
class Derived extends Base
{
private $privattrib = "bute";
function GetAttrib()
{
parent::GetAttrib();
}
}
$b = new Base();
$d = new Derived();
$d->GetAttrib();
?>
So for the code above I have a couple questions:
When I call parent::GetAttrib(), does the value of $this (in the Base's GetAttrib() method) become a Base object now or is it still a Derived object?
The ouput is "Private Attribute1". If $this refers to a Derived object, shouldn't the display be "bute" since the private attribute is overrided in the base class?
If I change both privaattrib to public, the output is now "bute". Why is this?