doushengyou2617 2012-12-04 05:07
浏览 42
已采纳

PHP错误报告 - 使用“^”字符和“〜”字符

I'm try to understand the difference between the use of the "^" character and the "~" character when setting the error_reporting values. For example I have the following in my php script:

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);
}

I've read the manual page at:

http://php.net/manual/en/function.error-reporting.php

but I'm now more confused than ever. Is:

error_reporting(E_ALL & ~ E_DEPRECATED & ~ E_USER_DEPRECATED & ~ E_NOTICE);

the same as:

error_reporting(E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED ^ E_NOTICE);
  • 写回答

2条回答 默认 最新

  • doushou8730 2012-12-04 05:11
    关注

    those are bitwise operators: http://php.net/manual/en/language.operators.bitwise.php

    error_reporting(E_ALL & ~ E_DEPRECATED & ~ E_USER_DEPRECATED & ~ E_NOTICE);
    

    would mean E_ALL and NOT E_DEPRECATED and NOT E_USER_DEPRECATED & NOT E_NOTICE

    while

    error_reporting(E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED ^ E_NOTICE);
    

    would mean E_ALL except E_DEP.... etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入