bitfield::get PHP Method

get() public method

public get ( $n )
    function get($n)
    {
        // Get the ($n / 8)th char
        $byte = $n >> 3;
        if (strlen($this->data) >= $byte + 1) {
            $c = $this->data[$byte];
            // Lookup the ($n % 8)th bit of the byte
            $bit = 7 - ($n & 7);
            return (bool) (ord($c) & 1 << $bit);
        } else {
            return false;
        }
    }

Usage Example

function has_flash_enabled($bitfield_data)
{
	$bitfield = new bitfield($bitfield_data);
	return $bitfield->get(11);
}
All Usage Examples Of bitfield::get