HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gzseek

Description

The gzseek of zlib for PHP seeks a position on the gz-file pointer.

Syntax

gzseek(
    resource $stream,
    int $offset,
    int $whence = SEEK_SET
): int

Parameters

stream

The gz-file pointer. It must be valid, and must point to a file successfully opened by gzopen().

offset

The seeked offset.

whence

whence values are:

ConstantDescription
SEEK_SETSet position equal to offset bytes. Default.
SEEK_CURSet position to current location plus offset.

Return

Returns 0 on success, returns -1 otherwise.

Seeking past EOF is not considered an error.

Examples

1 · stream offset

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz";
$mode = "r";

$stream = gzopen($filename, $mode);

    if($stream === false)
    {
        die("gzopen");
    }

    $offset = 2;

    $return = gzseek($stream, $offset);

    echo $return . PHP_EOL;

    gzpassthru($stream);

gzclose($stream);
0
ta

2 · whence · SEEK_SET

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz";
$mode = "r";

$stream = gzopen($filename, $mode);

    if($stream === false)
    {
        die("gzopen");
    }

    gzgetc($stream);

    $offset = 2;
    $whence = SEEK_SET;

    $return = gzseek($stream, $offset, $whence);

    echo $return . PHP_EOL;

    gzpassthru($stream);

gzclose($stream);
0
ta

3 · whence · SEEK_CUR

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/gz/1.gz";
$mode = "r";

$stream = gzopen($filename, $mode);

    if($stream === false)
    {
        die("gzopen");
    }

    gzgetc($stream);

    $offset = 2;
    $whence = SEEK_CUR;

    $return = gzseek($stream, $offset, $whence);

    echo $return . PHP_EOL;

    gzpassthru($stream);

gzclose($stream);
0
a