note 62068 deleted from function.define by tularis

From: Date: Sun, 03 Jun 2007 09:39:51 +0000
Subject: note 62068 deleted from function.define by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127149@lists.php.net to get a copy of this message
Note Submitter: bobbykjack at yahoo dot co dot uk ---- benjamin, I recognise your warning, but surely a key point of constants is that their values should NOT be referenced anywhere other than their definition. richard, your solution could be made slightly safer with the use of a function for this process, e.g. <?php $iRuleVal = 0; adefine ('RULE_CALLBACK_FORMAT'); adefine ('RULE_CHANGE_CALLBACK_ON_ERROR'); adefine ('RULE_CHANGE_COMPARE_DATE'); // etc. // 'a' for auto function adefine($constant_name) { global $iRuleVal; if (defined($constant_name)) { // error handling should go here return; } // good idea to use pre-increment; avoids use of 0 // and associated equality issues with empty string // via type conversion define($constant_name, ++$iRuleVal); } ?> I think you also misnamed the original local variable - it should be $iRuleVal.

« previous php.notes (#127149) next »