3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bar { private 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 Z8jYe
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to private method Bar::test() from context '' in /in/hjfPk:42 Stack trace: #0 {main} thrown in /in/hjfPk on line 42
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Call to private method Bar::test() from context '' in /in/hjfPk on line 42
Process exited with code 255.