无法在PHP中创建文本文件(nginx)

时间:2014-10-31 07:59:57

标签: php nginx

我在我的网站目录的根目录中有这个:

$filename = "test01.txt"; //the name of our file.
$content = "This is our test file"; //what we will be writing to our file.
$strlength = strlen($content); //gets the length of our $content string.
$create = fopen($filename, "w"); //uses fopen to create our file.
$write = fwrite($create, $content, $strlength); //writes our string to our file.
$close = fclose($create); //closes our file
echo("File Created, Click <a href='$filename'> Here </a> to view it.");

我只是想用PHP脚本创建一个文本文件,但它不起作用。 你知道吗? 谢谢

1 个答案:

答案 0 :(得分:0)

确保dir是可写的(组www),你也可以使用函数file_put_contents

file_put_contents($ create,$ content);