title: PHP fopen() not creating file if it doesn't already exist
body: <p>As part of application logging, I'm attempting to open a local file, and if that file doesn't already exist, to create the new one.  Here's what I have:</p>
  
  <pre><code>$path = '/home/www/phpapp/logs/myawesome_logfile.txt';
  $f = (file_exists($path))? fopen($path, "a+") : fopen($path, "w+");
  fwrite($f, $msg);
  fclose($f);
  chmod($path, 0777);
  </code></pre>
  
  <p>I've double-checked, and the <code>/logs</code> directory is chmod 0777, and I even went the extra step of chown'ing it to apache:apache for good measure.  Still, when the script goes to open the file, it gives me the warning that the file doesn't exist and bombs out.  No file is ever created.</p>
  
  <p>Do I need to suppress the <code>fopen()</code> warning to get it to create the file?</p>