Re: Bit manipulation (newbie)
| From: | Philip Hallstrom | Date: | Fri, 25 Apr 2003 18:49:19 +0000 |
| Subject: | Re: Bit manipulation (newbie) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145304@lists.php.net to get a copy of this message | ||
something like this might work:
define('ERROR_WRONG_EMAIL', 2);
define('ERROR_WRONG_PASSWD', 4);
$error = $error | ERROR_WRONG_EMAIL; // sets error
if( $error & ERROR_WRONG_EMAIL ) {
// checks to see if error is set
}
creating some simple "setError" and "isError" functiosn makes this even
simpler...
good luck.
-philip
On Fri, 25 Apr 2003, Karina S wrote:
> Hi,
>
> I want to store user errors. I want to store it as a bit. For example if
> user write wrong email it sets the 2.bit to 1 and if the user write wrong
> password set the 3. bit to 1. Is it any good way to set and get the bit
> values in php?
>
> Now I use :
> Write: code = code + 2; code = code + 4; //wrong email and wrong password
> Read: if (code == 2 || code == 6) //wrong eamil
>
> But it is not a nice sollution if I have 6-8 bit.
>
> Any idea?
>
> Thanks!
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>