tags:

views:

29

answers:

2

I want to put some text into the Apache error log (listens on the stderror error stream) from PHP using file_put_contents.
I am missing the name of this stream, and whether I have to put :// or something similar before it.

Thanks

+2  A: 

See http://php.net/manual/en/wrappers.php.php

$log = fopen("php://stderr", "a"); 
fwrite($log, "test message"); 
fclose($log);

But you might want to use the error_log function instead.

dreeves
+2  A: 

From http://php.net/manual/en/wrappers.php.php

php://stdin, php://stdout and php://stderr allow direct access to the corresponding input or output stream of the PHP process. It is recommended that you simply use the constants STDIN, STDOUT and STDERR instead of manually opening streams using these wrappers.

Chadwick