note 62253 deleted from language.constants by cmb

From: Date: Sun, 06 Sep 2015 15:34:15 +0000
Subject: note 62253 deleted from language.constants by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203716@lists.php.net to get a copy of this message
Note Submitter: martin at larsen dot dk ---- I find variables much more flexible than constants because variables can be used inside quotes and heredocs etc. Especially for language systems, this is nice. As stated in one of the previous notes, there is no speed penalty by using variables. However, one issue is that you risc name collision with existing variables. When implementing a language system I simply found that adding a prefix to all the variables was the way to go, for example: $LNG_myvar1 = "my value"; That is easier and performs faster than using arrays like $LNG['myvar'] = "my value"; As a final note, implementing a new superglobal in PHP would make using constants much more beneficial. Then it could be used in qoutes like this: "The constant myconst has the value $CONSTANTS[myconst] !"

« previous php.notes (#203716) next »