我试图了解设置error_reporting值时使用“^”字符和“〜”字符的区别。例如,我已在我的PHP脚本如下:PHP错误报告 - 使用“^”字符和“〜”字符
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
error_reporting(E_ALL & ~ E_DEPRECATED & ~ E_USER_DEPRECATED & ~ E_NOTICE);
} else {
error_reporting(E_ALL^E_NOTICE);
}
我在阅读手册页:
http://php.net/manual/en/function.error-reporting.php
,但我现在比以往任何时候都更加困惑。方法是:
error_reporting(E_ALL & ~ E_DEPRECATED & ~ E_USER_DEPRECATED & ~ E_NOTICE);
一样:
error_reporting(E_ALL^E_DEPRECATED^E_USER_DEPRECATED^E_NOTICE);
'^'不是'或',它是'xor'。 – DCoder
是的,我刚刚意识到这一点,并修复。谢谢 – kennypu
谢谢 - 所以我正确的结论是(E_ALL&〜E_DEPRECATED&〜E_USER_DEPRECATED&〜E_NOTICE)产生与(E_ALL^E_DEPRECATED^E_USER_DEPRECATED^E_NOTICE)相同的结果? – user982124