PHP: double output of php errors / warnings / notices
If I execute the following script:
<?php
error_reporting(E_ALL);
trigger_error('test notice', E_USER_NOTICE);
die('end of script');
I get the following output:
<br />
<b>Notice</b>: test notice in <b>path/to/script/test.php</b> on line <b>3</b><br />
end of scriptPHP Notice: test notice in path/to/script/test.php on line 3
The script was executed on IIS8 with PHP Version 5.4.19.
The http status code returned is 200.
"display_errors" is set to "On" and "error_reporting" to "E_ALL" in the php.ini file. So the first line of the script is just for clarification.
The behaviour is the same with all error reporting constants (E_ERROR, E_WARNING, etc.).
Does anyone know where the second output of the notice comes from? And especially how the get rid of it?
If you set both
error_reporting(E_ALL);
ini_set('display_errors', 1);
The errors will be doubled:
PHP Notice: Undefined variable: test in /path/to/script.php on line 8
Notice: Undefined variable: test in /path/to/script.php on line 8
Try turning one or the other off or a set a custom error handler.
First line in your script
error_reporting(E_ALL);Sets PHP to report all errors and with
display_errors
directive enabled in your PHP configuration which sets PHP to print errors to the screen, then no need to your second line which duplicates the output. To solve this issue I had to change the base settings of the site in IIS: "Connect As" with the IIS_USER and the double output of php error messages were gone! I still don't know why, but at least it works.
链接地址: http://www.djcxy.com/p/58928.html上一篇: 预定义的常量在PHP中对于像交易者这样的模块意味着什么
下一篇: PHP:PHP错误/警告/通知的双重输出