3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private function foo() { echo "success!" . get_class($this) . \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 */ } } $b = new B(); $b->test(); $c = new C(); $c->test(); //fails
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17, 7.0.0 - 7.0.2
Parse error: syntax error, unexpected '"', expecting ',' or ';' in /in/ETEna on line 5
Process exited with code 255.

preferences:
157.4 ms | 1395 KiB | 28 Q