Reputation: 9916
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?
Upvotes: 5
Views: 5709
Reputation: 42048
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.
Upvotes: 12