note 85156 deleted from language.operators.bitwise by danielc

From: Date: Mon, 13 Apr 2009 16:15:03 +0000
Subject: note 85156 deleted from language.operators.bitwise by danielc
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153176@lists.php.net to get a copy of this message
Note Submitter: darkelder at php dot net Reason: 2 ---- Here is a usefull class to work with flags: <?php class flags { function has_flag($flags, $flag_check) { if (($flags & $flag_check) == $flag_check) { return true; } return false; } function add_flag($flags, $flag_check) { // already have the flag, so return it as it is if ($this->has_flag($flags, $flag_check)) { return $flags; } return $flags ^ $flag_check; } function del_flag($flags, $flag_check) { // already have not the flag, so return it as it is if (!$this->has_flag($flags, $flag_check)) { return $flags; } return $flags ^ $flag_check; } } ?>

« previous php.notes (#153176) next »