Re: how to mark protected properties?
| From: | Greg Beaver | Date: | Mon, 07 Jun 2004 23:32:41 +0000 |
| Subject: | Re: how to mark protected properties? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30112@lists.php.net to get a copy of this message | ||
Scott Mattocks wrote:
Michael Wallner wrote:<?php class pclass {Even though PHP 5 makes this more intuitive with keywords and realI may be wrong but I was under the impression that extended methods must have an access level equal to or more strict than the parent's method. If I am right then you wouldn't have to worry about methods with underscores ever becoming public. Scott Mattocksimplementation of the intended functionality of protected and private properties and methods I think preceeding them with an underscore makes them easier to spot.What if they get declared public in extending classes?
protected $var = 'hi';
protected function show()
{
echo $this->var;
}
}
class cclass extends pclass
{
public $var;
public function show()
{
parent::show();
}
}
$a = new pclass;
$b = new cclass;
$b->show();
$b->var = "look it works!\n";
$b->show();
$a->show();
?>
:)
Greg