PHPのは、fgetc()関数
定義と使用法
fgetc関数()関数は、開いているファイルから単一の文字を返します。
文法
fgetc(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的文件。 |
ヒントと注意事項
注:この機能は非常にゆっくりと大きなファイルを扱うので、大きなファイルを扱うことができません。あなたは大きなファイルから順次文字を読み取る必要がある場合は、()関数fgetsを使用するデータを順次の行を読み込み、その後のfgetc()ラインを順次処理されたデータを使用します。
例1
<?php
$file = fopen("test2.txt","r");
echo fgetc($file);
fclose($file);
?>
$file = fopen("test2.txt","r");
echo fgetc($file);
fclose($file);
?>
意志出力上のコード:
H
例2
文字によってファイルをお読みください。
<?php
$file = fopen("test2.txt","r");
while (! feof ($file))
{
echo fgetc($file);
}
fclose($file);
?>
$file = fopen("test2.txt","r");
while (! feof ($file))
{
echo fgetc($file);
}
fclose($file);
?>
意志出力上のコード:
Hello, this is a test file.
PHPファイルシステムリファレンスマニュアルを完了