我一直在进行测验,并且遇到需要将答案保存到文本文件的情况。我想出了一些代码:<?php $myfile = fopen("myfile.txt", "r+") or die("Unable to open file!"); $txt = "Name:\n"; fwrite($myfile, $txt); $txt = "Student1\n"; fwrite($myfile, $txt); $txt = "Marks:\n"; fwrite($myfile, $txt); $txt = "0\n"; fwrite($myfile, $txt); echo fread($myfile,filesize("myfile.txt")); fclose($myfile);?>但我注意到,这只想写入内容已存在的文件,而无法创建新文件并写入它。有什么办法可以做到这一点吗?
添加回答
举报
0/150
提交
取消