note 84182 added to language.oop5.constants

From: Date: Wed, 02 Jul 2008 13:12:27 +0000
Subject: note 84182 added to language.oop5.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-141067@lists.php.net to get a copy of this message
The major problem of constants is for me, you cant use them for binary flags. <?php class constant { const MODE_FLAG_1 = 1; const MODE_FLAG_2 = 2; const MODE_FLAG_3 = 4; const DEFAULT_MODE = self::FLAG_1 | self::FLAG_2 private function foo ($mode=self::DEFAULT_MODE) { // some operations } } ?> This code will not work because constants can't be an calculation result. You could use <?php const DEFAULT_MODE = 3; ?> instead, but we use flags to be value indipendent. So you would miss target with it. Only way is to use defines like ever before. ---- Server IP: 212.124.37.9 Probable Submitter: 217.89.78.118 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php Edit -- https://master.php.net/note/edit/84182 Del: integrated -- https://master.php.net/note/delete/84182/integrated Del: useless -- https://master.php.net/note/delete/84182/useless Del: bad code -- https://master.php.net/note/delete/84182/bad+code Del: spam -- https://master.php.net/note/delete/84182/spam Del: non-english -- https://master.php.net/note/delete/84182/non-english Del: in docs -- https://master.php.net/note/delete/84182/in+docs Del: other reasons-- https://master.php.net/note/delete/84182 Reject -- https://master.php.net/note/reject/84182 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141067) next »