在PHP中的ftell()函數

PHPz
發布: 2023-08-27 11:10:01
轉載
1305 人瀏覽過

在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
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!