3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class C { const ENC = 1; const DEC = 2; /*const A = [ self::ENC => 'e', self::DEC => 'd' ];*/ protected $a = [ self::ENC => 'E', self::DEC => 'D' ]; } $c = new C(); print_r($c->a);
based on 6f9nZ
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Cannot access protected property C::$a in /in/WS4u2:20 Stack trace: #0 {main} thrown in /in/WS4u2 on line 20
Process exited with code 255.
Output for 5.4.2 - 5.6.21
Fatal error: Cannot access protected property C::$a in /in/WS4u2 on line 20
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/WS4u2 on line 12
Process exited with code 255.