&之间的差异和&&在PHP中 [英] Difference between & and && in PHP

查看:84
本文介绍了&之间的差异和&&在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对&&&感到困惑.我有两本PHP书.一个说它们是相同的,但是另一个说它们是不同的.我以为他们也一样.

I am confused with & and &&. I have two PHP books. One says that they are same, but the another says they are different. I thought they are same as well.

不是吗?

推荐答案

&是按位AND.请参见按位运算符.假设您执行14 & 7:

& is bitwise AND. See Bitwise Operators. Assuming you do 14 & 7:

    14 = 1110
     7 = 0111
    ---------
14 & 7 = 0110 = 6

&&是逻辑AND.参见逻辑运算符.考虑一下真值表:

&& is logical AND. See Logical Operators. Consider this truth table:

 $a     $b     $a && $b
false  false    false
false  true     false
true   false    false
true   true     true

这篇关于&之间的差异和&&在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆