2023-08-27

在PHP中的ftell()函数

在PHP中的ftell()函数

ftell()函数返回打开文件的当前位置。该函数返回当前文件指针位置。如果失败,则返回FALSE。

语法

ftell(file_pointer)
登录后复制

参数

  • file_pointer − 使用fopen()创建的文件指针。必需。

返回值

ftell()函数返回当前文件指针位置。如果失败,返回FALSE。

示例

<?php
   $file_pointer = fopen("new.txt","r");
   echo ftell($file_pointer);
   fclose($file_pointer);
?>
登录后复制

输出

0
登录后复制

让我们看另一个例子,其中当前位置被改变。

示例

<?php
   $file_pointer = fopen("new.txt","r");
   // changing current position
   fseek($file_pointer,"10");
   // displaying current position
   echo ftell($file_pointer);
   fclose($file_pointer);
?>
登录后复制

The following is the output. The current position is returned.

输出

10
登录后复制

以上就是在PHP中的ftell()函数的详细内容,更多请关注php中文网其它相关文章!

https://www.php.cn/faq/598414.html

发表回复

Your email address will not be published. Required fields are marked *