"; // "w" 表示以写入模式打开文件 $file = fopen($filename, "a") or die("Unable to open file!"); $txt = $name; $txt1 = "\r\n"; // 需要写入的数据 fwrite($file, $txt); fwrite($file, $txt1); fclose($file); } else { echo "文件不存在,已新建成功!"; $filename = "test.txt"; // 文件名 // "w" 表示以写入模式打开文件 $file = fopen($filename, "w") or die("Unable to open file!"); $txt = "写入第一条\r\n"; // 需要写入的数据 $txt1 = "写入第二条\r\n"; $txt2 = "写入第三条1\r\n"; fwrite($file, $txt); fwrite($file, $txt1); fwrite($file, $txt2); fclose($file); } $lines = file('test.txt'); foreach($lines as $line){ echo $line.""; } ?> 复制代码
"; // "w" 表示以写入模式打开文件 $file = fopen($filename, "a") or die("Unable to open file!"); $txt = $name; $txt1 = "\r\n"; // 需要写入的数据 fwrite($file, $txt); fwrite($file, $txt1); fclose($file); } else { echo "文件不存在,已新建成功!"; $filename = "test.txt"; // 文件名 // "w" 表示以写入模式打开文件 $file = fopen($filename, "w") or die("Unable to open file!"); $txt = "写入第一条\r\n"; // 需要写入的数据 $txt1 = "写入第二条\r\n"; $txt2 = "写入第三条1\r\n"; fwrite($file, $txt); fwrite($file, $txt1); fwrite($file, $txt2); fclose($file); } $lines = file('test.txt'); foreach($lines as $line){ echo $line.""; } ?>