All Questions
3
questions
4
votes
1
answer
814
views
Why can child override and access its parent private method?
I'm used to put method as protected in my PHP classes. But playing with private I'm starting to have doubts.
I know that it might be a duplicate but I can't find clarity from the SO-answers I've ...
4
votes
1
answer
5k
views
Private method overriding and visibility
I'm having a hard time trying to understand the output of the following code:
class Bar
{
public function test() {
$this->testPublic();
$this->testPrivate();
}
...
23
votes
3
answers
22k
views
Strange behavior when overriding private methods
Consider the following piece of code:
class foo {
private function m() {
echo 'foo->m() ';
}
public function call() {
$this->m();
}
}
class bar extends foo {
...