按位运算结果,输出时出现奇怪的行为
看来我的上一个问题更新尚未被注意到,因此一个新问题。
#dump1
var_dump('two identical strings' | 'two identical strings'); # mind the |
// string(21) "two identical strings"
#dump2
var_dump('two identical strings' ^ 'two identical strings'); # mind the ^
// string(21) ""
为什么#dump2
显示 length == 21,但输出没有/不可见的符号?
另外,当粘贴到 Notepad++ 中时,该字符串内也没有 21 个符号的迹象,好吧实际上,甚至没有 1 个符号,这与使用不等字符串的不同操作的输出相反。
那些 (DC3)
、(DC4)
等没有显示在浏览器中,但显示在 Notepad++ 中。
哦,实际上,该字符串中的那些黑色值是什么? 我猜测这些是位级/汇编程序级值,但是,呵呵,猜测!== true
。
提前致谢!
It looks like my previous question update haven't been noticed, therefore a new question.
#dump1
var_dump('two identical strings' | 'two identical strings'); # mind the |
// string(21) "two identical strings"
#dump2
var_dump('two identical strings' ^ 'two identical strings'); # mind the ^
// string(21) ""
Why #dump2
shows that length == 21, but outputs none/invisible symbols?
Plus, when pasted in Notepad++ there are no signs of 21 symbols inside that string either, well actually, not even 1 symbol, as opposed to this output from different operation with unequal strings.
Those (DC3)
, (DC4)
etc. didn't show up in browser, but shows up in Notepad++.
Oh, and actually, what are those blackish values inside that string? I'm guessing those are bit-level/assembler-level values, but, huh, guess !== true
.
将字节序列与自身进行异或基本上会将所有位设置为 0。因此,您将得到一长串 x00 字节,即
NUL
字符,它在屏幕上没有可读的表示形式。对任何类型的字符串进行按位运算通常会导致相当随机的位序列,无法在屏幕上显示为可读字符。你看到的随机黑色东西是 Notepad++ 尽力呈现字节序列。XORing a byte sequence with itself basically sets all bits to 0. So you have a long string of x00 bytes, which is the
NUL
character, which has no readable representation on screen. Doing bitwise operations on any sort of string will usually result in rather random bit sequences that can not be displayed on screen as readable characters. That random black stuff you see is Notepad++ trying its best to render a byte sequence.