开发者

Bitwise operation result, strange behavior when outputted

开发者 https://www.devze.com 2023-03-14 08:35 出处:网络
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 |

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 ou开发者_Python百科tput from different operation with unequal strings.

Bitwise operation result, strange behavior when outputted

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.

Thanks in advance!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消