private static function _byteStrToIntStr($byteStr) {
        // Get byte count.
        $byteCount = self::_byteCount($byteStr);

        // Check if byte count is not 0.
        if ($byteCount == 0) {
            $msg = 'Empty byte-string cannot be convertet to integer.';
            throw new InvalidArgumentException($msg, self::E_EMPTY_BYTESTRING);
        }

        // Try to use PHP's internal integer type.
        if ($byteCount <= PHP_INT_SIZE) {
            $int = 0;
            for ($i = 0; $i < $byteCount; $i++) {
                $int <<= 8;
                $int |= ord($byteStr[$i]);
            }
            if ($int >= 0)
                return $int;
        }

        // If we did not already return here, either the byte-string has more
        // characters (bytes) than PHP_INT_SIZE, or the conversion resulted in a
        // negative integer. In both cases, we need to use PHP's BC Math library and
        // return the integer as string.
        if (extension_loaded('bcmath')) {
            $intStr = '0';
            for ($i = 0; $i < $byteCount; $i++) {
                $intStr = bcmul($intStr, '256', 0);
                $intStr = bcadd($intStr, (string) ord($byteStr[$i]), 0);
            }
            return $intStr;
        } else {
            throw new RuntimeException('BC Math functions are not available.', self::E_NO_BCMATH);
        }
    }
private static function _byteStrToIntStr($byteStr) {
        // Get byte count.
        $byteCount = self::_byteCount($byteStr);

        // Check if byte count is not 0.
        if ($byteCount == 0) {
            $msg = 'Empty byte-string cannot be convertet to integer.';
            throw new InvalidArgumentException($msg, self::E_EMPTY_BYTESTRING);
        }

        // Try to use PHP's internal integer type.
        if ($byteCount <= PHP_INT_SIZE) {
            $int = 0;
            for ($i = 0; $i < $byteCount; $i++) {
                $int <<= 8;
                $int |= ord($byteStr[$i]);
            }
            if ($int >= 0)
                return $int;
        }

        // If we did not already return here, either the byte-string has more
        // characters (bytes) than PHP_INT_SIZE, or the conversion resulted in a
        // negative integer. In both cases, we need to use PHP's BC Math library and
        // return the integer as string.
        if (extension_loaded('bcmath')) {
            $intStr = '0';
            for ($i = 0; $i < $byteCount; $i++) {
                $intStr = bcmul($intStr, '256', 0);
                $intStr = bcadd($intStr, (string) ord($byteStr[$i]), 0);
            }
            return $intStr;
        } else {
            throw new RuntimeException('BC Math functions are not available.', self::E_NO_BCMATH);
        }
    }
private static function _byteStrToIntStr ( $ byteStr ) { // Get byte count. $ byteCount = self :: _byteCount ( $ byteStr ) ; // Check if byte count is not 0. if ( $ byteCount == 0 ) { $ msg = 'Empty byte-string cannot be convertet to integer.' ; throw new InvalidArgumentException ( $ msg , self :: E_EMPTY_BYTESTRING ) ; } // Try to use PHP's internal integer type. if ( $ byteCount <= PHP_INT_SIZE ) { $ int = 0 ; for ( $ i = 0 ; $ i < $ byteCount ; $ i ++ ) { $ int <<= 8 ; $ int |= ord ( $ byteStr [ $ i ] ) ; } if ( $ int >= 0 ) return $ int ; } // If we did not already return here, either the byte-string has more // characters (bytes) than PHP_INT_SIZE, or the conversion resulted in a // negative integer. In both cases, we need to use PHP's BC Math library and // return the integer as string. if ( extension_loaded ( 'bcmath' ) ) { $ intStr = '0' ; for ( $ i = 0 ; $ i < $ byteCount ; $ i ++ ) { $ intStr = bcmul ( $ intStr , '256' , 0 ) ; $ intStr = bcadd ( $ intStr , ( string ) ord ( $ byteStr [ $ i ] ) , 0 ) ; } return $ intStr ; } else { throw new RuntimeException ( 'BC Math functions are not available.' , self :: E_NO_BCMATH ) ; } }
Converts a byte-string into a non-negative integer.

Uses PHP's BC Math library if the integer represented by the given bytes
is too big to be stored in PHP's internal integer type. In this case a
string containing the integer is returned, otherwise a native integer.

Example: $byteStr = 'AB' => ord($byteStr[0]) << 8 | ord($byteStr[1]) =
16706

@param string $byteStr Byte-string whose binary content shall be
converted to an integer.
@return mixed Non-negative integer or string representing a non-negative
integer.
@throws InvalidArgumentException
@throws RuntimeException
Converts a byte - string into a non - negative integer .