note 54986 added to language.oop5.visibility
| From: | Miguel | Date: | Thu, 21 Jul 2005 15:10:24 +0000 |
| Subject: | note 54986 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92259@lists.php.net to get a copy of this message | ||
A note about private members, the doc says "Private limits visibility only to the class that
defines the item" this says that the following code works as espected:
<?php
class A {
private $_myPrivate="private";
public function showPrivate()
{
echo $this->_myPrivate."\n";
}
}
class B extends A {
public function show()
{
$this->showPrivate();
}
}
$obj=new B();
$obj->show(); // shows "private\n";
?>
this works cause A::showPrivate() is defined in the same class as $_myPrivate and has access to it.
----
Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54986
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54986&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54986&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54986&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54986&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54986&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54986&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54986&report=yes
Search -- http://master.php.net/manage/user-notes.php