我刚开始从互联网学习 php。我看到了一些文件处理的例子。但是,当我按照相同的程序进行文件写入时,它不起作用。
阅读功能是工作文件。但是写入文件不起作用。我也试过用file_put_content函数来写。:(
<?php
if(isset($_POST['submit1'])){
$fileName = "Text.txt";
$fh = fopen($fileName,"a") or die("can not open the file to write");
//Writing to a file
$newData = "Hello This is new Data";
fwrite($fh,$newData);
fclose($fh);
//Reading a file -- Working
$text = fopen("Text.txt","r") or die ("can not open the file to read");
while(!feof($text))
{
$myLine = fgets($text);
print $myLine;
}
fclose($text);
}
?>
请指导我..谢谢