|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-03 12:39 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 08:00:01 2025 UTC |
Description: ------------ It doesn't appear that you can change the access modifiers on constants - are they public by default? It seems to make more sense to be able to define access modifiers on constants (since you can with every other component in classes). Consistency? Reproduce code: --------------- <?php class Foo { const a = 1; public const b = 2; private const c = 3; static function bar() { return c; } } echo Foo::a; echo Foo::b; echo Foo::c; echo Foo::bar(); ?> Expected result: ---------------- 1 2 ERROR: Cannot access a private constant 'c' 3 Actual result: -------------- Parse error: parse error, unexpected T_CONST, expecting T_VARIABLE in C:\Web\construct\php\php5test\test10.php on line 4 PHP Parse error: parse error, unexpected T_CONST, expecting T_VARIABLE in C:\Web\construct\php\php5test\test10.php on line 4