note 87818 deleted from language.oop5.overloading by cmb

From: Date: Sun, 18 Dec 2016 10:03:23 +0000
Subject: note 87818 deleted from language.oop5.overloading by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208654@lists.php.net to get a copy of this message
Note Submitter: jorge dot hebrard at gmail dot com ---- This is a great way to give different permissions to parent classes. <?php class A{ private $b; function foo(){ $this->b = new B; echo $this->b->protvar; } } class B extends A{ protected $protvar="protected var"; public function __get($nm) { echo "Default $nm value"; } } $a = new A; $b = new B; $a->foo(); // prints "protected var" echo $b->protvar; // prints "Default protvar value" ?> This way, you can help parent classes to have more power with protected members.

« previous php.notes (#208654) next »