src/Server/Asyn/MQTT/Utility.php
static public function PackStringWithLength($str)
    {
        $len = strlen($str);
        # UTF-8
        if (!self::ValidateUTF8($str)) {
            throw new Exception('Bad UTF-8 String');
        }
        return pack('n', $len) . $str;
    }
static public function PackStringWithLength($str)
    {
        $len = strlen($str);
        # UTF-8
        if (!self::ValidateUTF8($str)) {
            throw new Exception('Bad UTF-8 String');
        }
        return pack('n', $len) . $str;
    }
static public function PackStringWithLength ( $ str ) { $ len = strlen ( $ str ) ; # UTF-8 if ( ! self :: ValidateUTF8 ( $ str ) ) { throw new Exception ( 'Bad UTF-8 String' ) ; } return pack ( 'n' , $ len ) . $ str ; }
Pack string with a 16-bit big endian length ahead.

@param string $str  input string
@return string      returned string
@throws Exception
Pack string with a 16 - bit big endian length ahead .