public static function readString(&$buffer)
    {
        $tmp = unpack('n', $buffer);
        $length = array_pop($tmp);
        if ($length + 2 > strlen($buffer)) {
            throw new \RuntimeException("buffer:".bin2hex($buffer)." lenth:$length not enough for unpackString");
        }

        $string = substr($buffer, 2, $length);
        $buffer = substr($buffer, $length + 2);
        return $string;
    }
public static function readString(&$buffer)
    {
        $tmp = unpack('n', $buffer);
        $length = array_pop($tmp);
        if ($length + 2 > strlen($buffer)) {
            throw new \RuntimeException("buffer:".bin2hex($buffer)." lenth:$length not enough for unpackString");
        }

        $string = substr($buffer, 2, $length);
        $buffer = substr($buffer, $length + 2);
        return $string;
    }
public static function readString ( & $ buffer ) { $ tmp = unpack ( 'n' , $ buffer ) ; $ length = array_pop ( $ tmp ) ; if ( $ length + 2 > strlen ( $ buffer ) ) { throw new \ RuntimeException ( "buffer:" . bin2hex ( $ buffer ) . " lenth:$length not enough for unpackString" ) ; } $ string = substr ( $ buffer , 2 , $ length ) ; $ buffer = substr ( $ buffer , $ length + 2 ) ; return $ string ; }
Read string from buffer.
@param $buffer
@return string
@see https://github.com/walkor/mqtt/blob/master/src/Protocols/Mqtt.php#readString
Read string from buffer .