public static function getLV(&$p, $l = 1, $nul = false, $lrev = false)
    {
        $s = static::b2i(static::binarySubstr($p, 0, $l), !!$lrev);
        $p = static::binarySubstr($p, $l);

        if ($s == 0) {
            return '';
        }

        $r = '';

        if (strlen($p) < $s) {
            echo("getLV error: buf length (" . strlen($p) . "): " . Debug::exportBytes($p) . ", must be >= string length (" . $s . ")\n");

        } else if ($nul) {
            if ($p{$s - 1} != "\x00") {
                echo("getLV error: Wrong end of NUL-string (" . Debug::exportBytes($p{$s - 1}) . "), len " . $s . "\n");
            } else {
                $d = $s - 1;
                if ($d < 0)
                {
                    $d = 0;
                }
                $r = static::binarySubstr($p, 0, $d);
                $p = static::binarySubstr($p, $s);
            }

        } else {
            $r = static::binarySubstr($p, 0, $s);
            $p = static::binarySubstr($p, $s);
        }

        return $r;
    }
public static function getLV(&$p, $l = 1, $nul = false, $lrev = false)
    {
        $s = static::b2i(static::binarySubstr($p, 0, $l), !!$lrev);
        $p = static::binarySubstr($p, $l);

        if ($s == 0) {
            return '';
        }

        $r = '';

        if (strlen($p) < $s) {
            echo("getLV error: buf length (" . strlen($p) . "): " . Debug::exportBytes($p) . ", must be >= string length (" . $s . ")\n");

        } else if ($nul) {
            if ($p{$s - 1} != "\x00") {
                echo("getLV error: Wrong end of NUL-string (" . Debug::exportBytes($p{$s - 1}) . "), len " . $s . "\n");
            } else {
                $d = $s - 1;
                if ($d < 0)
                {
                    $d = 0;
                }
                $r = static::binarySubstr($p, 0, $d);
                $p = static::binarySubstr($p, $s);
            }

        } else {
            $r = static::binarySubstr($p, 0, $s);
            $p = static::binarySubstr($p, $s);
        }

        return $r;
    }
public static function getLV ( & $ p , $ l = 1 , $ nul = false , $ lrev = false ) { $ s = static :: b2i ( static :: binarySubstr ( $ p , 0 , $ l ) , ! ! $ lrev ) ; $ p = static :: binarySubstr ( $ p , $ l ) ; if ( $ s == 0 ) { return '' ; } $ r = '' ; if ( strlen ( $ p ) < $ s ) { echo ( "getLV error: buf length (" . strlen ( $ p ) . "): " . Debug :: exportBytes ( $ p ) . ", must be >= string length (" . $ s . ")\n" ) ; } else if ( $ nul ) { if ( $ p { $ s - 1 } != "\x00" ) { echo ( "getLV error: Wrong end of NUL-string (" . Debug :: exportBytes ( $ p { $ s - 1 } ) . "), len " . $ s . "\n" ) ; } else { $ d = $ s - 1 ; if ( $ d < 0 ) { $ d = 0 ; } $ r = static :: binarySubstr ( $ p , 0 , $ d ) ; $ p = static :: binarySubstr ( $ p , $ s ) ; } } else { $ r = static :: binarySubstr ( $ p , 0 , $ s ) ; $ p = static :: binarySubstr ( $ p , $ s ) ; } return $ r ; }
Parse length-value structure.

@param &string $p
@param int $l number of length bytes.
@param bool $nul Null-terminated, defaults to false.
@param bool $lrev Little-endian, default to false.
@return string
Parse length - value structure .