一,123按位与45 的结果是0 ,在PHP代码中 ‘123’ & ‘45’ 结果为‘00’
二,在PHP手册中是这样描述的:If both operands for the &, | and ^ operators are strings, then the operation will be performed on the ASCII values of the characters that make up the strings and the result will be a string. In all other cases, both operands will be converted to integers and the result will be an integer. (字符串与字符串的结果是字符串,整型与整型的结果是整型)
三,解决方法: 修改代码 $jieguo = $Num1 & $Num2; 为 $jieguo = (int)$Num1 & (int)$Num2; 即可。
|