0
我刚刚开始从互联网学习,我很新。我看到了一些文件处理的例子。但是,当我按照文件的相同步骤时,它不起作用。获取用户输入到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);
}
?>
请指导我.. 感谢
它不工作,因为它显示“无法打开文件写入“? – 2012-08-14 09:37:48
你应该检查你的文件夹/文件的权限 - 帐户是否有权访问该文件来写?发布您收到的错误消息以帮助确定问题。 – Fluffeh 2012-08-14 09:38:19
是的,此消息出现在文件写入部分。但在文件阅读的情况下,它工作正常。 – 2012-08-14 09:39:19