3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bar { public function test() { $this->testPrivate(); $this->privatefoo(); } private function testPrivate() { echo "Bar::testPrivate\n"; } } class Foo extends Bar { private function testPrivate() { echo "Foo::testPrivate\n"; } private function privatefoo(){ echo "Foo::privatefoo"; } public function testFooScope() { $this->testPrivate(); } } class Zot extends Foo { } $myZot = new Zot(); $myZot->test(); //What would this do other than Bar::testPrivate $myZot->testFooScope();
based on EtJK2
Output for 7.0.0 - 7.2.0
Bar::testPrivate Fatal error: Uncaught Error: Call to private method Foo::privatefoo() from context 'Bar' in /in/Z8jYe:8 Stack trace: #0 /in/Z8jYe(42): Bar->test() #1 {main} thrown in /in/Z8jYe on line 8
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Bar::testPrivate Fatal error: Call to private method Foo::privatefoo() from context 'Bar' in /in/Z8jYe on line 8
Process exited with code 255.