Hi,
I'm trying to figure out bitwise operators, as a test I put my name in hexadecimal and now I try to display the ascii values.
This is the output:
255
127
255
255
255
Somewhat strange if you take a look at $intTest and the code below ...
If the two last characters are deleted (6E and 6F), the output is as I would expect.
Can someone please explain why there is a problem with these values (6E and 6F)?
Thanks!
Bruno
The code follows:
//hextest
$intTest=0x4272756E6F;
/*
binary:
01000010 = 66
01110010 = 114
01110101 = 117
01101110 = 110
01101111 = 111
*/
for($i=4;$i>=0;$i--) {
echo (($intTest >> $i*8) & 0xFF).'<br>'; //*8 omdat 1 karakter = 1 byte = 8 bits
}