【发布时间】:2012-02-26 03:15:02
【问题描述】:
可能重复:
What does this ~ operator mean here?
Bit not operation in PHP(or any other language probably)
谁能解释一下 PHP 中的 ~ 运算符?我知道是NOT-operator,但是PHP为什么要把下面的语句转换成变量的负值减一呢?
$a = 1; echo ~$a // echo -2
$a = 2; echo ~$a // echo -3
$a = 3; echo ~$a // echo -4
【问题讨论】:
-
有关这方面的信息可在整个互联网上获得
-
在副本中,没有任何与二进制补码运算相关的内容,这就是这个问题的本质。我怀疑它是 exact 重复的。但是,这个this question 涵盖了完全相同的问题。
标签: php operators bit-manipulation tilde