我正在使用Windows操作系统,并且对PHP很陌生。 我想在PHP文件中实现php函数fgets():
$file = fopen("$DOCUMENT_ROOT/Chapter02/test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
我已创建了test.txt文件,其内容如下:
作为来自http://www.w3schools.com/的示例。Hello, this is a test file.
There are three lines here.
This is the last line.
两个文件,.php和.txt都位于一个目录中:
C:/wamp/www/Chapter02/
但执行此php文件后,没有显示任何内容,应该显示:
我想,我在"$DOCUMENT_ROOT/Chapter02/test.txt"路径上犯了错误,但我真的不知道错误在哪里...Hello, this is a test file.
There are three lines here.
This is the last line.
我非常感谢您的帮助:)
顺祝商祺,
伊万娜