Error presenting messages in binary CLI file

test.php contains the following line:

<?php echo 1 / 0; ?>

PHP version 5.4.0 (cli)

Now a series of tests with display_errors:

  • display_errors = Off image1
  • display_errors = stderr image2
  • display_errors = stdout image3

Why Offdoes not turn off the display of errors on stdout?

Why did the two stdoutand stderrend up printing on both outputs simultaneously?

+5
source share
1 answer

Why does Off turn off error display on standard output?

I suppose because error_log is not set. If it is installed, errors are not displayed. If it is not installed, PHP will use the SAPI error log, which is stderr (= stdout) in the CLI. Cm:

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 at the same time?

​​ SAPI, ​​ stdout (display_errors = on). , , , SAPI stderr, .

+12

All Articles