note 113894 deleted from language.oop5.constants by cmb

From: Date: Tue, 22 Feb 2022 09:58:07 +0000
Subject: note 113894 deleted from language.oop5.constants by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217639@lists.php.net to get a copy of this message
Note Submitter: keenskelly at gmail dot com ---- Re: "The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call." I dare say that "a mathematical operation" can indeed be a constant expression. I was quite surprised by this limitation; you cannot, for example do something like: const LIMITMB = 20; const LIMITB = LIMITMB * 1024 * 1024; It is very common to be able to express something like that in other languages, like C with #defines, where changing one definition has a cascading effect on others without having to pre-calculate hard-coded numbers all over the place. So beware, you might be better off using a private static or global contstant definition if you need to do anything more sophisticated than a name=primitive value pair.

« previous php.notes (#217639) next »