private function getEncoding(string &$string): string
    {
        # Check for the UTF-8 byte order mark
        if (substr($string, 0, 3) === self::UTF8) {
            $string = substr($string, 3);
            return self::UTF8;
        }

        # Check for the UTF-16 big endian byte order mark
        if (substr($string, 0, 2) === self::UTF16BE) {
            $string = substr($string, 2);
            return self::UTF16BE;
        }

        # Check for the UTF-16 little endian byte order mark
        if (substr($string, 0, 2) === self::UTF16LE) {
            $string = substr($string, 2);
            return self::UTF16LE;
        }

        return self::UNKNOWN;
    }
private function getEncoding(string &$string): string
    {
        # Check for the UTF-8 byte order mark
        if (substr($string, 0, 3) === self::UTF8) {
            $string = substr($string, 3);
            return self::UTF8;
        }

        # Check for the UTF-16 big endian byte order mark
        if (substr($string, 0, 2) === self::UTF16BE) {
            $string = substr($string, 2);
            return self::UTF16BE;
        }

        # Check for the UTF-16 little endian byte order mark
        if (substr($string, 0, 2) === self::UTF16LE) {
            $string = substr($string, 2);
            return self::UTF16LE;
        }

        return self::UNKNOWN;
    }
private function getEncoding ( string & $ string ) : string { # Check for the UTF-8 byte order mark if ( substr ( $ string , 0 , 3 ) === self :: UTF8 ) { $ string = substr ( $ string , 3 ) ; return self :: UTF8 ; } # Check for the UTF-16 big endian byte order mark if ( substr ( $ string , 0 , 2 ) === self :: UTF16BE ) { $ string = substr ( $ string , 2 ) ; return self :: UTF16BE ; } # Check for the UTF-16 little endian byte order mark if ( substr ( $ string , 0 , 2 ) === self :: UTF16LE ) { $ string = substr ( $ string , 2 ) ; return self :: UTF16LE ; } return self :: UNKNOWN ; }
Get the encoding of a BOM declared string, and remove the bom.

@param string $string The data to examine

@return string The encoding of the string
Get the encoding of a BOM declared string and remove the bom .