Skip to main content
The 2024 Developer Survey results are live! See the results

All 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 ...
Kamafeather's user avatar
  • 9,481
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(); } ...
renatov's user avatar
  • 5,065
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 { ...
NullUserException's user avatar