Can';t使用PHPMAC(Xampp)打开.txt文件

Can';t使用PHPMAC(Xampp)打开.txt文件,php,macos,fopen,Php,Macos,Fopen,下面是代码给我的错误消息: 警告:fopen(users.txt):无法打开流:第79行/opt/lampp/htdocs/assignment3/form.php中的权限被拒绝 无法打开文件 这是我的密码: $file = fopen("users.txt", "a") or die("Unable to open file."); 我刚开始用mac编写代码,所以我对它不太了解。提前感谢您的帮助运行此代码以轻松找到正确的文件夹 &l

下面是代码给我的错误消息:

警告:fopen(users.txt):无法打开流:第79行/opt/lampp/htdocs/assignment3/form.php中的权限被拒绝 无法打开文件

这是我的密码:

$file = fopen("users.txt", "a") or die("Unable to open file.");

我刚开始用mac编写代码,所以我对它不太了解。提前感谢您的帮助

运行此代码以轻松找到正确的文件夹

<?php

$txt = 'users.txt';

echo '<br> your php file is here : ' . __FILE__;

echo '<br> your text file should exists in : ' . __DIR__ . '/' . $txt;

echo '<br> your text file '.( file_exists($txt)?'exists':'not exists' );

echo '<br> your text file is '.( is_readable($txt)?'readable':'not readable' );

echo '<br> your text file is '.( is_writable($txt)?'writable':'not writable' );

echo '<br> your dir is '.(
        is_writable(__DIR__)?
            'writable, then you can create new files':
            'not writable, then you can not create any files'
    );