note 113894 added to language.oop5.constants

From: Date: Fri, 13 Dec 2013 20:42:19 +0000
Subject: note 113894 added to language.oop5.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-197930@lists.php.net to get a copy of this message
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. ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/language.oop5.constants.php Edit -- https://master.php.net/note/edit/113894 Del: integrated -- https://master.php.net/note/delete/113894/integrated Del: useless -- https://master.php.net/note/delete/113894/useless Del: bad code -- https://master.php.net/note/delete/113894/bad+code Del: spam -- https://master.php.net/note/delete/113894/spam Del: non-english -- https://master.php.net/note/delete/113894/non-english Del: in docs -- https://master.php.net/note/delete/113894/in+docs Del: other reasons-- https://master.php.net/note/delete/113894 Reject -- https://master.php.net/note/reject/113894 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197930) next »