I am trying to extend the PHP class without rewriting all this. Here is an example:
<? $a = new foo(); print $a->xxx(); $b = new bar(); print $b->xxx(); class foo { const something = 10; public function xxx() { $this->setSomething(); return $this->something; } private function setSomething() { $this->something = self::something; } } class bar extends foo { public function xxx() { $this->setSomething(); $this->something++; return $this->something; } } ?>
However, when I run the script, I get the following error:
Fatal error: Call to private method foo::setSomething() from context 'bar' in test.php on line 23
It would seem that bar does not inherit the private setSomething () function. How can I fix this without changing the foo class?
source share