title: Writing to php://stderr
body: <p>I'm trying to get the use of php://stderr for writing logs to work. I'm using Slim framework which makes use of <code>@fopen('php://stderr', 'w')</code> for logging and really want this to work.</p>
  
  <p>The following test cases should work but only the first one does: </p>
  
  <pre><code>// 1. error_log - works fine
  error_log("Written through the error_log function", 0);
  
  // 2. PHP wrapper, ie php://stderr - does not work
  $stderr = fopen( 'php://stderr', 'w' );
  fwrite($stderr, "Written through the PHP error stream" );
  fclose($stderr);
  
  
  // 3. PHP wrapper also, different syntax, just to be safe - no effect either
  file_put_contents( "php://stderr","Hello World" );
  
  
  // 4. PHP wrapper, this time using this elusive constant referred to in the manual - result: "Notice: Use of undefined constant STDERR - assumed 'STDERR' ", ie: failed also!
  file_put_contents( STDERR, "Hello World" );
  </code></pre>
  
  <p>I've been looking through the PHP manual and Googling a lot but without much help. </p>
  
  <p>In particular, the following quote from the PHP manual <a href="http://php.net/manual/en/wrappers.php.php" rel="noreferrer">on wrappers</a> is confusing:</p>
  
  <blockquote>
    <p>It is recommended that you simply use the constants STDIN, STDOUT and STDERR instead of manually opening streams using these [referring php://stdin, php://stdout and php://stderr] wrappers."</p>
  </blockquote>
  
  <p>...given the undefined constant notice above. (I suspect those constants might be for use with PHP CLI -only?- but the page I'm citing does not state it.) </p>
  
  <p>I've been wondering if this could be a Windows thing as I'm running XAMPP with PHP 5.3.8 for development but given the lack of topics on Google and the comments on PHP.net, I'm not so sure anymore. I do not have access to my production server logs right now for me to test out. </p>