public static function skip_varint($fp)
    {
        $len = 0;
        do { // Keep reading until we find the last byte
            $b = fread($fp, 1);
            if ($b === false) {
                throw new Exception("skip(varint): Error reading byte");
            }
            $len++;
        } while ($b >= "\x80");

        return $len;
    }