- 论坛徽章:
- 1
|
还是来自于手册:
http://cn.php.net/manual/zh/ref.errorfunc.php#errorfunc.constants
The above values (either numerical or symbolic) are used to build up a bitmask that specifies which errors to report. You can use the bitwise operators to combine these values or mask out certain types of errors. Note that only '|', '~', '!', '^' and '&' will be understood within php.ini, however, and that no bitwise operators will be understood within php3.ini.
链接到:http://cn.php.net/manual/zh/language.operators.bitwise.php
位运算符
位运算符允许对整型数中指定的位进行置位。如果左右参数都是字符串,则位运算符将操作字符的 ASCII 值。
<?php
echo 12 ^ 9; // 输出为 '5'
echo "12" ^ "9"; // 输出退格字符(ascii 8)
// ('1' (ascii 49)) ^ ('9' (ascii 57)) = #8
echo "hallo" ^ "hello"; // 输出 ascii 值 #0 #4 #0 #0 #0
// 'a' ^ 'e' = #4
?>
表 15.3. 位运算符
例子 名称 结果
$a & $b And(按位与) 将把 $a 和 $b 中都为 1 的位设为 1。
$a | $b Or(按位或) 将把 $a 或者 $b 中为 1 的位设为 1。
$a ^ $b Xor(按位异或) 将把 $a 和 $b 中不同的位设为 1。
~ $a Not(按位非) 将 $a 中为 0 的位设为 1,反之亦然。
$a << $b Shift left(左移) 将 $a 中的位向左移动 $b 次(每一次移动都表示“乘以 2”)。
$a >> $b Shift right(右移) 将 $a 中的位向右移动 $b 次(每一次移动都表示“除以 2”)。 |
|