note 75982 added to language.oop5.constants
| From: | rlee0001 at osu1 dot php dot net | Date: | Mon, 25 Jun 2007 16:52:06 +0000 |
| Subject: | note 75982 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127957@lists.php.net to get a copy of this message | ||
For people who, for readability sake, used to create "flag" constants like so:
<?php
define("MYLIB_SHOW_HEADER", 1 << 0);
define("MYLIB_SHOW_FOOTER", 1 << 1);
define("MYLIB_SHOW_ALL", MYLIB_SHOW_HEADER | MYLIB_SHOW_FOOTER);
...
?>
The equiv with class constants must instead read:
<?php
MyLib class {
SHOW_HEADER = 1;
SHOW_FOOTER = 2;
SHOW_ALL = 3;
...
}
?>
Which gets very unreadable very quickly when lots of flags are involved (e.g. SHOW_ALL must be
created and maintained manually).
----
Server IP: 69.147.83.197
Probable Submitter: 71.42.115.242
----
Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php
Edit -- https://master.php.net/note/edit/75982
Del: integrated -- https://master.php.net/note/delete/75982/integrated
Del: useless -- https://master.php.net/note/delete/75982/useless
Del: bad code -- https://master.php.net/note/delete/75982/bad+code
Del: spam -- https://master.php.net/note/delete/75982/spam
Del: non-english -- https://master.php.net/note/delete/75982/non-english
Del: in docs -- https://master.php.net/note/delete/75982/in+docs
Del: other reasons-- https://master.php.net/note/delete/75982
Reject -- https://master.php.net/note/reject/75982
Search -- https://master.php.net/manage/user-notes.php