[英]PHP Error reporting on demand
In PHP how do you make it so that it will only display errors when using the error_reporting() function. 在PHP中,您如何制作它,使其仅在使用error_reporting()函数时显示错误。 Currently the IIS PHP application is set to 'Production machine'.
当前,IIS PHP应用程序设置为“生产机器”。 If I change it to Development machine it will print out all errors even without error_reporting().
如果将其更改为Development Machine,即使没有error_reporting(),它也会打印出所有错误。
error_reporting
may be set by your application and override the php.ini setting. error_reporting
可能由您的应用程序设置,并且覆盖了php.ini设置。
In any case, you should never turn it off. 无论如何, 永远不要关闭它。
Instead, change display_errors
to Off
in php.ini, or in your code: 而是在php.ini或您的代码中将
display_errors
更改为Off
:
ini_set('display_errors', 0);
On your "Production machine" you can toggle the error_reporting on and off... directly in your PHP script. 在“生产机器”上,您可以直接在PHP脚本中打开和关闭error_reporting...。
You can also find this in your php.ini file on your server to set the default. 您也可以在服务器上的php.ini文件中找到它来设置默认值。
<?php
// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
?>
我得到了想要使用的行为:
error_reporting(E_ALL); ini_set('display_errors', 1);
Do 做
error_reporting(0);
work for you? 为你工作?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.