For example, 3^3 .
What does this mean and how to implement in PHP like?

    3 answers 3

    ^ - Bitwise exclusive OR (XOR).
    They [bitwise operators] are identical (by and large) in both JS and PHP .

    • what does bitwise mean? what are they? - ikerya
    • Read the article in the answer - you will find a lot of interesting things, in two words you will not describe. - user207618
    • okay thank you. - ikerya

    This is a bitwise XOR operator; it operates on bits of a number. The easiest way to understand the meaning of bitwise operators is to convert decimal numbers to binary. For example, the decimal number 3 in binary form is 11. And 2 is 10. This is how bitwise AND AND (operator & ) acts

     3 & 2 = 2 11 (3) 10 (2) 10 (2) 

    1 and 1 gives 1, 1 and 0 gives 0, 0 and 0 gives 0. In the following way, OR OR acts (operator | )

     3 | 2 = 3 11 (3) 10 (2) 11 (3) 

    1 and 1 gives 1, 1 and 0 gives 1, 0 and 0 gives 0. Exclusive OR XOR (operator ^ ) works as follows

     3 ^ 2 = 1 11 (3) 10 (2) 01 (1) 

    1 and 1 gives 0, 1 and 0 gives 1, 0 and 0 gives 0.

    • Great answer. Only you are sure that you need to leave the conclusions "how it works" to the author and those who will then read it? Where is the explanation of how the bits are modified? Since I took up the tug ... - user207618
    • 0^0=0 , not one, one - only if the arguments differ, if they match - 0 - Grundy
    • @Grundy thanks for the comment, corrected the answer. - cheops

    The symbol ^ usually in expressions has two values ​​- xor or degree.
    xor bitwise is written as 3 ^ 3 . And the degree is recorded as pow(3,3) .

    • In JS is possible to raise a power like this: 3 ** 3 , ^ only changes bits. - user207618
    • the cap symbol is raised to the exponent. And somewhere else I saw it. - KoVadim
    • Yes, wherever you need to write a degree, but the notebook does not allow. It is slightly confused, once confused in the example. - user207618
    • @Other, and where in the JS it is possible to raise a power like this: 3 ** 3 ? - Grundy