将其作为嵌套逻辑处理。首先检查$config['errors']
并启用或禁用error_reporting
与E_ALL
或0
。
从
error_reporting
设置通过调用
error_reporting()
内获得的电流值
然后减E_WARNING
。
if ($config['errors']) {
// Enable all
error_reporting(E_ALL);
// Then subtract warnings from the current value
// by calling error_reporting() as its own argument
if (!$config['warnings']) {
error_reporting(error_reporting() & ~E_WARNING);
}
}
else {
// Or disable everything.
error_reporting(0);
}
你没有具体提及E_NOTICE
但我怀疑你想那些禁用了。
error_reporting(error_reporting() & ~E_WARNING & ~E_NOTICE);
如果你希望入手的东西比E_ALL
少一点,你可能需要删除您在php.ini管理这个E_DEPRECATED
和E_STRICT
if ($config['errors']) {
// Enable all (but a little less than all)
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
// Then check warnings, etc...
}
不应该? – Pogrindis
我想这样做的原因是因为我想编码自己的错误系统 – user3684526
@Pogrindis我不知道该怎么做:/ – user3684526