定义

fgetc()函数从打开的文件返回单个字符。

 

语法

PHP fgetc()函数具有以下语法。

fgetc(file)

 

参数

参数 是否必须 描述
file 需要。 要检查的文件

 

返回值

PHP fgetc()函数从打开的文件返回单个字符。

 

实例1

<?php
$file = fopen(\"data.txt\",\"r\");
echo fgetc($file);
fclose($file);
?>

 

实例2

逐个字符读取文件:

<?php
/*
http://www.manongjc.com/article/1777.html
作者:码农教程
*/
$file = fopen(\"data.txt\",\"r\");

while (! feof ($file)){
  echo fgetc($file);
}

fclose($file);
?>
收藏 打印