fgetc
從文件指針中讀取字符
fgetc()
函數從文件指針中讀取一個字符。
<?php $file = fopen ( "test.txt" , "r" ) ; echo fgetc ( $file ) ; fclose ( $file ) ; ?>
輸出類似:
H
<?php $file = fopen ( "test.txt" , "r" ) ; while ( ! feof ( $file ) ) { echo fgetc ( $file ) ; } fclose ( $file ) ; ?>
輸出類似:
Hello, this is a test file.
fgetc ( file )
參數 | 描述 |
---|---|
file | 必需。規定要檢查的文件。 |
返回一個包含有一個字符的字符串,該字符從file指向的文件中得到。碰到EOF 則返回false。
文件指針必須有效,並且必須指向一個由fopen()
或fsockopen()
成功打開(但還沒有被fclose()
關閉)的文件。