看起来像是 fgets 返回的每个内容之间都加了一个空格。 以下是一些示例代码:
<?php
Echo "Opening " . $_SERVER{'DOCUMENT_ROOT'} . "/file.txt" . "...<br>";
$FileHandle = @Fopen($_SERVER{'DOCUMENT_ROOT'} . "/file.txt", "r");
If ($FileHandle){
Echo "File opened:<br><br>";
While (!Feof($FileHandle)){
$Line = Fgets($FileHandle);
Echo $Line . "word<br>"; //Should be LINECONTENTSword, no space.
}
Fclose($FileHandle);
}
?>
返回
Opening /var/www/vhosts/cqe.me/httpdocs/file.txt...
File opened:
First line word
Second line word
3rd line word
Another line of text word
Blablablaword
为什么行的内容和“word”之间有空格?为什么文件末尾(Blablablaword)没有这个空格?
请问如何去掉这个空格?
谢谢 :-)!