title: How to output the reason for a PHP file open failure
body: <p>I'm trying to debug a huge, antiquated (circa 2001) PHP web service and I'm encountering file open failures.  The fopen call is in an included module, the caller is logging that the file could not be opened but no reason is being logged.</p>
  
  <p>The code that actually does the open is:</p>
  
  <pre><code>  // Read the file
    if (!($fp = @fopen($fileName, 'rb'))) {
      $errStr = "Failed to open '{$fileName}' for read.";
      break; // try-block
    }
  </code></pre>
  
  <p>How can I find out why fopen failed?</p>