首頁  >  文章  >  後端開發  >  在PHP中的ftell()函數

在PHP中的ftell()函數

PHPz
PHPz轉載
2023-08-27 11:09:091159瀏覽

在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.com。如有侵權,請聯絡admin@php.cn刪除