|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-09-11 17:07 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2020-09-11 17:07 UTC] requinix@php.net
[2020-09-20 04:22 UTC] php-bugs at lists dot php dot net
[2020-09-22 13:25 UTC] flexjoly at vfweb dot nl
[2020-09-22 17:08 UTC] requinix@php.net
-Status: No Feedback
+Status: Feedback
[2020-09-22 17:08 UTC] requinix@php.net
[2020-09-25 13:02 UTC] flexjoly at vfweb dot nl
-Status: Feedback
+Status: Open
[2020-09-25 13:02 UTC] flexjoly at vfweb dot nl
[2021-01-13 18:39 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2021-01-13 18:39 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 02:00:01 2025 UTC |
Description: ------------ Normal constants are made by the function 'define()'. But something like that is not possible for a class constant. That limits their purpose and usability very much. Can you please add a define-function for a class constant? Then we can use a class with constant to replace all the separate constants. Nowadays many variables are put in static classes and can be found and used easily. But when using these for config/settings etc. you need to set them public for direct access. But then they can be changed, and that is not wanted. A class constant solves this. For it can be used public, but cannot be changed. But for settings/config etc. it need to be possible to define a class constant from a variable or function, just like a normal constant. Test script: --------------- class myClass { const myConst; const otherConst = 'already set'; public function defineMyConst(){ // first time defining, works fine self::myConst = 'some value'; // second time defining not allowed, should throw an error self::myConst = 'other value'; // defining a defined constant is not allowed, and throws an error self::myConst = 'changing'; } }