3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private function foo() { echo "success!\n"; } public function test() { $this->foo(); static::foo(); } } class B extends A { /* foo() will be copied to B, hence its scope will still be A and * the call be successful */ } class C extends A { private function foo() { /* original method is replaced; the scope of the new one is C */ } } $c = new C(); $c->test(); //fails ?>

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
success! Fatal error: Uncaught Error: Call to private method C::foo() from context 'A' in /in/13UhM:8 Stack trace: #0 /in/13UhM(26): A->test() #1 {main} thrown in /in/13UhM on line 8
Output for Array change keys
success! Fatal error: Uncaught Error: Call to private method C::foo() from context 'A' in /in/13UhM:8 Stack trace: #0 /in/13UhM(26): A->test() #1 {main} thrown in /in/13UhM on line 8
Output for Lexical anon
success! Fatal error: Call to private method C::foo() from context 'A' in /in/13UhM on line 8

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page