Oihana PHP

hasAllFlags.php

Table of Contents

Functions

hasAllFlags()  : bool
Checks whether **all** specified flags are set in a bitmask.

Functions

hasAllFlags()

Checks whether **all** specified flags are set in a bitmask.

hasAllFlags(int $mask, int $flags) : bool

This function is useful when you want to ensure that a set of flags are all active within a bitmask.

Parameters
$mask : int

The original bitmask, potentially containing multiple flags combined with |.

$flags : int

The flags to check (can be a single flag or multiple combined with |).

Tags
example
use function oihana\core\bits\hasAllFlags;

const FLAG_A = 1 << 0; // 1
const FLAG_B = 1 << 1; // 2
const FLAG_C = 1 << 2; // 4

$mask = FLAG_A | FLAG_B ; // 3

hasAllFlags( $mask , FLAG_A ) ;          // true
hasAllFlags( $mask , FLAG_A | FLAG_B ) ; // true
hasAllFlags( $mask , FLAG_A | FLAG_C ) ; // false
author

Marc Alcaraz (ekameleon)

since
1.0.7
Return values
bool

Returns true if all the given flags are present in the mask, false otherwise.


        
On this page

Search results