|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27022 Class constant has no visibility modificator
Submitted: 2004-01-23 12:47 UTC Modified: 2015-12-23 19:55 UTC
Avg. Score:4.6 ± 0.6
Reproduced:25 of 25 (100.0%)
Same Version:3 (12.0%)
Same OS:16 (64.0%)
From: Assigned: seander (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2004-01-23 12:47 UTC]
It is not possible to use visibility modificator like public/protected/private on a class constant.

Reproduce code:
php -r "class fubar { protected const some_const = 123; }"

Actual result:
PHP Parse error:  parse error, unexpected T_CONST, expecting T_VARIABLE in Command line code on line 1


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-21 19:38 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2011-09-15 09:01 UTC] pulzarraider at gmail dot com
It would be great if php will have private/protected constants inside classes. It's very important feature for every real object programming language. If it would be available, the status of PHP, as a programming language, will grow.
 [2015-01-08 22:40 UTC]
-PHP Version: 5CVS-2004-01-23 (dev) +PHP Version: 7.0
 [2015-01-08 22:40 UTC]
This looks reasonable, bumping version.
 [2015-08-19 19:14 UTC] sean at siobud dot com
This seems to be a dupe of

I started working on this, and will open a PR against php-src in the next couple of days. I don't intended on it getting merged anytime soon, but it is fun to work on.
 [2015-12-23 19:55 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: seander
 [2015-12-23 19:55 UTC]
This was merged and available in master, the first release that will have it is (7.1)

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Sep 27 08:05:51 2022 UTC