如何在 php 中创建一个文件和数据存储?
How to create one file and data store in php?
$myFile = "folder1/folder2/order.txt";
$fh = fopen($myFile, 'a');fwrite($fh, $Message);
fclose($fh);
我正在使用这个 code.But 文件不是在那个特定文件夹中创建的
试试这个:
<?php
$myFile = "folder1/folder2/order.txt";
$fh = fopen($myFile, 'a'); or die("Unable to open the file");
fwrite($fh, $Message);
fclose($fh);
?>
如果此代码显示 "Unable to open the file",则表示打开文件时出现错误。如果 folder1/folder2
不存在,则可能会发生这种情况。也可能是您 不允许 打开要写入该文件夹的文件。如果您在 Linux
中,您可以像这样更改目录的权限:
chmod 777 folder/folder2
$myFile = "folder1/folder2/order.txt";
$fh = fopen($myFile, 'a');fwrite($fh, $Message);
fclose($fh);
我正在使用这个 code.But 文件不是在那个特定文件夹中创建的
试试这个:
<?php
$myFile = "folder1/folder2/order.txt";
$fh = fopen($myFile, 'a'); or die("Unable to open the file");
fwrite($fh, $Message);
fclose($fh);
?>
如果此代码显示 "Unable to open the file",则表示打开文件时出现错误。如果 folder1/folder2
不存在,则可能会发生这种情况。也可能是您 不允许 打开要写入该文件夹的文件。如果您在 Linux
中,您可以像这样更改目录的权限:
chmod 777 folder/folder2