3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class A { protected const c = null; abstract protected static function fs(); abstract protected function f(); } class B extends A { public function __construct(C $c) { var_dump(C::fs()); var_dump($c->f()); var_dump(C::C); } protected static function fs() {} protected function f() {} } class C extends A { protected const C = 'C::C'; protected static function fs() { return __METHOD__; } protected function f() { return __METHOD__; } } new B(new C);
Output for 7.1.0 - 7.3.0beta1
string(5) "C::fs" string(4) "C::f" Fatal error: Uncaught Error: Cannot access protected const C::C in /in/2lU3i:15 Stack trace: #0 /in/2lU3i(33): B->__construct(Object(C)) #1 {main} thrown in /in/2lU3i on line 15
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.25
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/2lU3i on line 4
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected T_CONST, expecting T_VARIABLE in /in/2lU3i:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: syntax error, unexpected T_CONST, expecting T_VARIABLE in /in/2lU3i:4 Stack trace: #0 {main}
Process exited with code 255.