test.php
contains the following line:
<?php echo 1 / 0; ?>
PHP version is 5.4.0 (cli)
Now, a series of tests with display_errors
:
display_errors = Off
display_errors = stderr
display_errors = stdout
Why does Off
not turn off error display on stdout
?
Why do both stdout
and stderr
end up printing to both outputs simultaneously?
Why does Off not turn off error display on stdout?
I suppose because error_log is not set. If it is set, errors are not displayed. If it not set, PHP will use the SAPI error logger, which is stderr (= stdout) in CLI. See:
ini_set('display_errors', 0);
echo 1 / 0; // Prints a warning.
ini_set('error_log', '/dev/null');
echo 1 / 0; // No warning on the standard output.
Why do both stdout and stderr end up printing to both outputs simultaneously?
The first error was sent to the SAPI error logger, the second was sent to stdout (display_errors = on). Both messages are displayed because as I mentioned above, the SAPI error logger is stderr, which is also stdout in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With