The operation process of solving'a'^'b'

if both sides of the ^ operator are integers, it will naturally convert the binary to do XOR operations, but what if they are all strings?

Php
Jun.02,2022

if it is two characters, it depends on whether the programming language you are using supports syntax:

there are operator overloading methods for ^ operators that match char ^ char .

if syntax allows, it depends on how the overloaded method is defined.

In general, the ASCII code values of arg1 and arg2 are taken directly and then the number ^ number operation is continued.

but for a string, it should not work unless you manually overload the ^ operator to support it, or how to take the number value for a string greater than 1 is undefined.


refer to the official PHP documentation: https://secure.php.net/manual...
wrote:

If both operands for the &, | and ^ operators are strings, then the operation will be performed on the ASCII values of the characters that make up the strings and the result will be a string.
When both sides of

are strings, the ASCII value will be taken, and the return value will be a string.

Menu