test1.txt文件内容如下:this is my first day come in island.this is my first day come in island.this is my first day come in island.this is my first day come in island.我的PHP文件——filesystem.php文件内容如下:$file = fopen("test1.txt","r");echo "<br>";while(!feof($file)){ echo fgetc($file); if(fgetc($file)==""){ echo "<br>"; }}fclose($file);在浏览器的输出如下:ti sm is a oei sad ti sm is a oei sad ti sm is a oei sad ti sm is a oei sad 请问这是什么情况?
1 回答
忽然笑
TA贡献1806条经验 获得超5个赞
PHP code?
$root = $_SERVER['DOCUMENT_ROOT'];
$file = fopen("$root/php_02/123.txt", "rb");
while(!feof($file)){
$char = fgetc($file);
if(!feof($file)):
echo $char == '\n'?'<br>':$char;
endif;
}
fclose($file);
书上说,fgetc函数会返回EOF,因此在循环内部用feof函数判断是否达到文件结束,如果到达就不回显在浏览器上。
我就有个疑问,
PHP code?
$char = fgetc($file);
- 1 回答
- 0 关注
- 70 浏览
添加回答
举报
0/150
提交
取消