note 87154 deleted from language.oop5.visibility by danbrown
| From: | danbrown@php.net | Date: | Fri, 21 Nov 2008 20:19:08 +0000 |
| Subject: | note 87154 deleted from language.oop5.visibility by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146808@lists.php.net to get a copy of this message | ||
Note Submitter: trashbinAThot mailDoTcom
----
To odessa-gun at ya dot ru
Sorry but the example is totally right.
In your code you just declare a new private member. It is not the original one that you modify.
Try this to understand :
<?php
class MyClass
{
public $public = 'Public';
protected $protected = 'Protected';
private $private = 'Private';
function printHello()
{
echo $this->public;
echo $this->protected;
echo $this->private;
}
}
class MyClass2 extends MyClass
{
public $public = 'Public2';
protected $protected = 'Protected2';
private $private = 'Private2';
function printHello()
{
// I have just added this to your code
parent::printHello(); //Accessing the overridden method. This will explain better than me
;)
echo $this->public;
echo $this->protected;
echo $this->private;
}
}
?>