現在の位置: ホーム> 関数カテゴリ一覧> feof

feof

ファイルポインターがファイルの最後に到達するかどうかをテストします
名前:feof
カテゴリ:ファイルシステム
対応言語:php
一言説明:ファイルポインターがファイルの最後に到達するかどうかをテストします。

<span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token variable">$ file</span> <span class="token operator">=</span> <span class="token function">fopen</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"test.txt"</span> <span class="token punctuation">、</span> <span class="token string double-quoted-string">"r"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>

<span class="token comment">//ファイルの最後までテキスト内のすべての行を出力します。</span>
<span class="token keyword">while</span> <span class="token punctuation">(</span> <span class="token operator">!</span> <span class="token function">feof</span> <span class="token punctuation">(</span> <span class="token variable">$ file</span> <span class="token punctuation">)</span> <span class="token punctuation">)</span>
  <span class="token punctuation">{</span>
  <span class="token keyword">echo</span> <span class="token function">fgets</span> <span class="token punctuation">(</span> <span class="token variable">$ file</span> <span class="token punctuation">)</span> <span class="token operator">。</span> <span class="token string double-quoted-string">"<br />"</span> <span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

<span class="token function">fclose</span> <span class="token punctuation">(</span> <span class="token variable">$ file</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

出力:

こんにちは、これはテストファイルです。 
ここには3つの行があります。 
これが最後の行です。
類似の関数
  • 取得したファイルのグループ filegroup

    filegroup

    取得したファイルのグループ
  • 一意のファイル名でファイルを作成します tempnam

    tempnam

    一意のファイル名でファイルを作成します
  • RealPathキャッシュエントリを取得します realpath_cache_get

    realpath_cache_get

    RealPathキャッシュエントリを取得
  • 開いたファイルポインターを閉じます fclose

    fclose

    開いたファイルポインターを閉じます
  • ファイルを特定の長さに切り捨てます ftruncate

    ftruncate

    ファイルを特定の長さに切り捨てます
  • ファイルポインターから行を読んで、CSVフィールドを解析する fgetcsv

    fgetcsv

    ファイルポインターから行を読んで、CSV
  • 軽量コンサルテーションファイルロック flock

    flock

    軽量コンサルテーションファイルロック
  • disk_free_spaceのエイリアス diskfreespace

    diskfreespace

    disk_free_spaceのエイリア