note 110850 deleted from language.operators.increment by danbrown
| From: | danbrown@php.net | Date: | Fri, 14 Dec 2012 17:43:02 +0000 |
| Subject: | note 110850 deleted from language.operators.increment by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192534@lists.php.net to get a copy of this message | ||
Note Submitter: f74 at nil
----
<?php
in reply to previous note...
class a {
private $foo = 1;
}
class b extends a {
public function inc() {
echo ++$this->foo;
}
}
$b = new b;
$b->inc();
?>
$foo is private, so can't be accessed by its children.
Simply change private for protected and ++$this->foo equals 2.