
PHP 官方文档中, Bitwise Operator 中有一段话:
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
使用 &, | 还有 ^ *** 作符的时候,只有 *** 作符两边的值都是 string 的时候,才会使用 ASCII 去运算,返回 string,其他的所有情况下,都会把值转换成 int。
你问题中的运算并非两个值都是字符串,所以都要被转成 int 计算。intval( 'a' ); 的结果是0,所以相当于 0 & 1
下载个ConvertZ,就能批量将ascii转成utf-8了 你看过后很简单吧以后不会可以向我一样经常到后盾人找找相关教材看看就会了,希望能帮到你,给个采纳吧谢谢凸(>皿<)凸
以上就是关于php位运算中为什么 'a'&1=0,而不是1,a的ascii码对应值是97,那不就是97&1=1吗全部的内容,包括:php位运算中为什么 'a'&1=0,而不是1,a的ascii码对应值是97,那不就是97&1=1吗、php ascii 怎么转成utf8、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)