note 46143 added to function.func-get-args
| From: | volte6 at drunkduck dot com | Date: | Thu, 30 Sep 2004 21:54:10 +0000 |
| Subject: | note 46143 added to function.func-get-args | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77629@lists.php.net to get a copy of this message | ||
For those who have a use for a C style enum() function:
//*******************************************
// void enum();
// enumerates constants for unique values guarenteed.
function enum()
{
$i=0;
$ARG_ARR = func_get_args();
if (is_array($ARG_ARR))
{
foreach ($ARG_ARR as $CONSTANT)
{
define ($CONSTANT, ++$i);
}
}
}
// USAGE:
enum(ERR_USER_EXISTS, ERR_OLD_POST);
// etc. etc.
//*******************************************
this can be used for error codes etc.
I deliberately skipped the 0 (zero) define, which could be useful for error checking.
----
Manual Page -- http://www.php.net/manual/en/function.func-get-args.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46143
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46143&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46143&report=yes
Search -- http://master.php.net/manage/user-notes.php