略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: gztell

2024-04-28

gztell

(PHP 4, PHP 5, PHP 7, PHP 8)

gztellTell gz-file pointer read/write position

说明

gztell(resource $stream): int|false

Gets the position of the given file pointer; i.e., its offset into the uncompressed file stream.

参数

stream

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

返回值

The position of the file pointer or false if an error occurs.

参见

add a noteadd a note

User Contributed Notes 1 note

up
0
Steve Ramage
15 years ago
ok so this function returns the gz file pointer as the uncompressed data byte length so if you are trying to put something in to specific size gzip files it won't work.

Example:

<?
//some_file.sql  filesize = 2,048,000 bytes

$text_fp=fopen('some_file.sql','r');
$gz_fp=gzopen('some_file.sql.gz','wb9');
while(!feof($text_fp)){
    gzwrite($gz_fp,fread($text_fp,655360));
}
fclose($text_fp);
echo "gztell = ".gztell($gz_fp)."<BR>\n";
gzclose($gz_fp);
echo "filesize = ".filesize('some_file.sql.gz')."<BR>\n";
?>

Output:

gztell = 2048000
filesize = 249264

I will report this as a bug but post a note here for now

官方地址:https://www.php.net/manual/en/function.gztell.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3