How to calculate the PHP CRC check Code (PHP xor)
For example, I have a string "139c", using a calculator to calculate the check code, copy the 13^9c= to the calculator with 16 binary calculation to calculate 8F is correct
Calculate with PHP:
echo Dechex (0x13^0x9c); The result is 8f, correct
echo "";
$s 1 = ' 0x13 ';
$s 2 = ' 0x9c ';
Echo Dechex ($s 1^ $s 2);//result is 0, error
echo "";
$s 3 = ' 13 ';
$s 4 = ' 9c ';
Echo Dechex ($s 3^ $s 4); Result is 0, error
Assigning a value to a variable is not the same as the result of the direct write, I wonder ... Would you please give me some pointers, or have a calculation function available?
------to solve the idea----------------------
$s 1 = 0x13;
$s 2 = 0x9c;
Echo Dechex ($s 1^ $s 2);
8f
No problem
------to solve the idea----------------------
$s 1 = hexdec (' 0x13 ');
$s 2 = hexdec (' 0x9c ');
Echo Dechex ($s 1^ $s 2); 8F
$s 3 = hexdec (' 13 ');
$s 4 = hexdec (' 9c ');
Echo Dechex ($s 3^ $s 4); 8F
This is normal.