Writing to php://stderr
php, stderr, windows, xampp
Solution
Never mind, got it. I did not quite get the difference between `php://stderr` and `error_log`:
`error_log` writes to the PHP error log (eg: D:\xampp\php\logs\php_error_log)
`php://stderr` writes to the server/Apache error log (eg: D:\xampp\apache\logs\error.log)
Hopefully this helps someone else.
Problem
I'm trying to get the use of php://stderr for writing logs to work. I'm using Slim framework which makes use of `@fopen('php://stderr', 'w')` for logging and really want this to work. The following test cases should work but only the first one does: ``` // 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" ); ``` I've been looking through the PHP manual and Googling a lot but without much help. In particular, the following quote from the PHP manual on wrappers is confusing: 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." ...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.) 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.