1. Go to this page and download the library: Download cruxinator/php-bitmask library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cruxinator / php-bitmask example snippets
use Cruxinator\BitMask\BitMask ;
class UserStatus extends BitMask
{
const Registered = 1; // BIT #1 of $flags has the value 1
const Active = 2; // BIT #2 of $flags has the value 2
const Member = 4; // BIT #3 of $flags has the value 4
const Admin = 8; // BIT #4 of $flags has the value 8
}
$status = UserStatus::Registered();
// or with a dynamic key:
$status = UserStatus::$key();
// or with a dynamic value:
$status = new UserStatus($value);
// values can then be checked
if ($status->isActive()){
// ...
}
// individuals flags can later toggled ON
$status->setActive(true);
// or off
$status->setActive(false);