3v4l.org

run code in 200+ php & hhvm versions
<?php class Foo { private const C1 = "a"; private const C2 = 'b'; } try { var_dump(constant('Foo::C1')); } catch(Error $e) { echo 'Caught',$e->getMessage(), PHP_EOL; } try{ Foo::C2; } catch(Error $e) { echo 'Caught',$e->getMessage() ,PHP_EOL; }
based on cd420
Output for 7.1.0
CaughtCannot access private const Foo::C1 CaughtCannot access private const Foo::C2
Output for 5.6.0 - 7.0.10
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/JY1AO on line 4
Process exited with code 255.