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

gzread

Description

The gzread of zlib for PHP binary-safe gz-file read.

Syntax

gzread(
    resource $stream,
    int $length
): string|false

Parameters

stream

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

length

The number of bytes to read.

Return

Returns the data that have been read, or false on failure.

Examples

1 · stream length · 1024

<?

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

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

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

    $return = "";
    $length = 1024;

    while(!feof($stream))
    {
        $return .= gzread($stream, $length);

        if($return === false)
        {
            die("gzread");
        }
    }

    echo $return;

gzclose($stream);

?>
data

2 · stream length · 2

<?

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

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

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

    $return = "";
    $length = 2;

    //while(!feof($stream))
    //{
        $return .= gzread($stream, $length);

        if($return === false)
        {
            die("gzread");
        }
    //}

    echo $return;

gzclose($stream);

?>
da
HomeMenu