fopen: failed to open stream: Permission denied in PHP on Mac
<p>I wrote this piece of code:</p>

<pre><code>if (file_exists("testfile.rtf")) echo "file exists.";
else echo "file doesn't exist.";

$fh = fopen("testfile.rtf", 'w') or die("impossible to open the file");

$text = &lt;&lt;&lt; _END
Hi buddies, 
I write for the first time
in a PHP file!
_END;

fwrite($fh, $text) or die("Impossible to write in the file");
fclose($fh);
echo ("writing in the file 'testfile.rtf' succeed.");
</code></pre>

<p>But when I run it it says:</p>

<blockquote>
  <p>fopen(testfile.rtf): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/test/test1.php on line 64
  impossible to open the file</p>
</blockquote>

<p>I use XAMPP on my MAC to work on local server.</p>

<p>I found several topics where some people had the same problem, and solved it using something called "chmod 777" but I don't know what that means, where to write this, etc. </p>