你的php没错,我的机器也是一样,"\n"也一样。
你要做记数器吗?
不要用echo输入到文件,同一时刻只能对文件读或写,
下面的php用文件指令来做,可以完成你的功能。
fopen 也可以create file.<?php
$File = "test.txt" ;
$Num = "0";
echo $File;
if (!file_exists($File)) {
echo "test file not exist.";
$fp = fopen($File,"w");
fputs($fp,$Num);
fclose($fp);
}
?>
你要做记数器吗?
不要用echo输入到文件,同一时刻只能对文件读或写,
下面的php用文件指令来做,可以完成你的功能。
fopen 也可以create file.<?php
$File = "test.txt" ;
$Num = "0";
echo $File;
if (!file_exists($File)) {
echo "test file not exist.";
$fp = fopen($File,"w");
fputs($fp,$Num);
fclose($fp);
}
?>
fopen 不能用rw来create file.
echo "\n"只相当于在html里的一个回车,当然要被忽略。
第二个问题:不要用\n用:echo"hello world.<br>";
因为PHP是专为网页制作而设计的,是由个别人(而不是组织)编写的,每一个函数都是为了应用。这也是它快速的原因。
问题解决了,别忘了加分哦!