The display_errors
directive (can be set everywhere) takes optionally the parameter "stderr
" for it to report errors to stderr instead of stdout or completely disabled error output. Quoting from the PHP manual entry:
Value "stderr" sends the errors to stderr instead of stdout. The value is available as of PHP 5.2.4.
Alternatively if you're using the commandline interface and you want to output the errors your own you can re-use the command-line nput/output streams:
fwrite(STDERR, 'error message');
Here STDERR
is an already opened stream to stderr.
Alternatively if you want to do it just for this script and not in CLI you can open a filed handler to php://stderr
and write the error messages there.
$fe = fopen('php://stderr', 'w');
fwrite($fe, 'error message');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…