在PHP中的ftell()函数

PHPz
PHPz 转载
2023-08-27 11:10:01 816浏览

在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中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除