Calculate the phpcrc verification code (PHP exclusive or). For example, if I have a segment string named "139c", use a calculator to calculate the verification code, copy 13 ^ 9c = to the calculator and calculate 8F in hexadecimal notation.
PHP computing:
Echo dechex (0x13 ^ 0x9c); // The result is 8f, correct echo ""; $ s1 = '0x13 '; $ s2 = '0x9c '; echo dechex ($ s1 ^ $ s2); // The result is 0. the error echo ""; $ s3 = '13'; $ s4 = '9c '; echo dechex ($ s3 ^ $ s4); // The result is 0, error
Assigning a value to a variable makes the calculation result different from that written directly... Please give us some advice or give a usable computing function
Reply to discussion (solution)
PHP and or operations, if both the front and back are strings, are performed using the asc code or
$ S1 = '0x13 ';
$ S2 = '0x9c ';
Convert to asc for comparison with or
'0' 'X' '1' '3'
00110000 01111000 00110001 00110011
^
00110000 01111000 00111001 01100011
----------------------------------------------------------------
00000000 00000000 00001000 01010000
The result is var_dump (chr (0). chr (0). chr (8). chr (80) should be string (4) "P" because three non-printable characters are used.
The dechex conversion starts from numeric characters (ASC does not recognize any other characters from 48 to 57) to the tail or non-numeric characters.
So the result is 0.
$s1 = 0x13;$s2 = 0x9c;echo dechex($s1^$s2);
8f
No problem
$ S1 = '0x13 ';
$ S2 = '0x9c ';
Is the character string 0x into the character
$ S1 = 0x13;
$ S2 = 0x9c;
These two are hexadecimal numbers. of course they are different.
$s1 = hexdec('0x13');$s2 = hexdec('0x9c');echo dechex($s1^$s2); // 8F$s3 = hexdec('13');$s4 = hexdec('9c');echo dechex($s3^$s4); // 8F
This is normal.