title: Permission denied, error log
body: <p>I'm trying to create a simple error log that write down php errors in case these cannot be reported to the admin (with a database connection). I wrote this:</p>
  
  <pre><code>function errorLog($array)
  {
      $time = date("F j, Y, g:i a");
      $ip = $_SERVER['REMOTE_ADDR'];
      $no = $array['e-no'];
      $string = $array['e-string'];
      $file = $array['e-file'];
      $line = $array['e-line'];
      $context = $array['e-context'];
  
      $string = "TIME {$time} IP {$ip} ERROR {$no} | {$string} | {$file} | {$line} | {$context}";
      if ($handler = fopen('log/log-file.txt', 'a'))
      {
          fwrite($handler, $string);
          fclose($handler);
      }
      else
      {
          exit('Fatal Error #0002');
      }
  }
  </code></pre>
  
  <p><strong>START EDIT</strong></p>
  
  <p>Function had became </p>
  
  <pre><code>function errorLog($array)
  {
      $time = date("F j, Y, g:i a");
      $ip = $_SERVER['REMOTE_ADDR'];
      $type = $array['e-type'];
      $string = $array['e-string'];
      $file = $array['e-file'];
      $line = $array['e-line'];
      $context = $array['e-context']
      $string = "ON {$time} IP {$ip} ERROR {$type} | {$string} | {$file} | {$line} | {$context}"; 
      if (!error_log($string, 3, 'log/log-file.txt')) { exit('Fatal Error #0002'); }
  }
  </code></pre>
  
  <p><strong>END EDIT</strong></p>
  
  <p>But when i run it i get </p>
  
  <pre><code>Warning: fopen(log/log-file.txt) [function.fopen]: failed to open stream: Permission denied in myfile.php on line 17
  </code></pre>
  
  <p>I got this is a server permission problem, but i am working on a localhost (Xampp on Mac os x) and i'd like to manage these permissions. How can i place log/ to be writable only? Is there any better ways of doing what i am trying to do?</p>