title: file_put_contents() to log errors works fine - EXCEPT for fatal errors
body: <p>So I figured out how to generate my own PHP error handler and record all errors in a log file - not visible to the user. I even made a second log file, that only records UNIQUE errors.</p>
  
  <p>Now I figured out how I can go about fatal errors, by calling 
  register_shutdown_function('fatal_handler');</p>
  
  <p>My fatal_handler utilized the same functions which my regular error handler uses, so that fatal errors get logged the exact same way.</p>
  
  <p>But here is where things get weird: When I invoke a fatal error, I get all these errors from my error logging functions:</p>
  
  <blockquote>
    <p>WARNING: file_put_contents(): open_basedir restriction in effect.
    File(errors.log) is not within the allowed path(s): ... </p>
    
    <p>WARNING: file_put_contents(errors.log): failed to open stream:
    Operation not permitted</p>
    
    <p>WARNING: fopen(unique_errors.log): failed to open stream: Operation
    not permitted</p>
  </blockquote>
  
  <p>And then subsequently  any fgets, fclose, and file_put_contents functions also fail with simmilar errors.</p>
  
  <p><strong>Why do these errors occur for the fatal_handler but not for the regular error handler?
  What do I have to do differently when logging fatal errors?</strong></p>
  
  <p><strong>E D I T :</strong></p>
  
  <p>*Maybe I should mention that the log file I am trying to access resides in a sub folder of on of the paths that the open_base_dir restriction error message lists as an option. So the error doesn't make sense, because it is within an allowed path - I mean after all it works effortless when it's just a NOTICE, rather than a FATAL ERROR.*</p>
  
  <p><em>So again my question:</em>
  <strong>Why does file_put_contents() work on the regular error handler but not in the fatal error handler?</strong></p>
  
  <p><em>I assume I have to specify the path to the file differently in the fatal error handler, because events are happening at a different level or something like that maybe...? I really know nothing about php's inner workings... Does anyone have an opinion or idea?</em></p>