3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private function privateFoo() { echo "private a\n"; } protected function protectedFoo() { echo "protected a\n"; } public function run() { $this->privateFoo(); $this->protectedFoo(); } } class B extends A { protected function protectedFoo() { echo "protected b\n"; } public function runB() { $this->privateFoo(); $this->protectedFoo(); } } $b = new B(); $b->run(); $b->runB();
based on eqNn9
Output for 7.0.0 - 7.2.0
private a protected b Fatal error: Uncaught Error: Call to private method A::privateFoo() from context 'B' in /in/ZQQZk:32 Stack trace: #0 /in/ZQQZk(39): B->runB() #1 {main} thrown in /in/ZQQZk on line 32
Process exited with code 255.
Output for 5.3.21 - 5.6.28
private a protected b Fatal error: Call to private method A::privateFoo() from context 'B' in /in/ZQQZk on line 32
Process exited with code 255.