提问人:LuisF 提问时间:11/7/2023 更新时间:11/7/2023 访问量:41
fgetc() 替换第一个字符
fgetc() replaces first character
问:
为什么第一个字符在第二个 While 中被替换?
删除串联后,它可以正常工作,但是当我尝试在文件中的字符之间获取任何字符时,就会发生这种情况。
法典
<?php
$stream = fopen('./text.txt', 'r');
while (!feof($stream)) {
$char = fgetc($stream);
echo $char;
};
fclose($stream);
echo PHP_EOL;
$stream = fopen('./text.txt', 'r');
while (!feof($stream)) {
//percorre cada linha do stream
$char = fgetc($stream);
echo "$char.";
};
fclose($stream);
文本.txt
Something
Something else
Other thing
结果
Something
Something else
Other thing
..o.m.e.t.h.i.n.g.
.S.o.m.e.t.h.i.n.g. .e.l.s.e.
.O.t.h.e.r. .t.h.i.n.g..
答: 暂无答案
评论
S.o.m.e.t.h.i.n.g. .S.o.m.e.t.h.i.n.g. .e.l.s.e. .O.t.h.e.r. .t.h.i.n.g..
while(!feof($file))
总是错的