I came across this line of code in an application I am revising:
substr($sometext1 ^ $sometext2, 0, 512);
What does the ^
mean?
In PHP, the double colon :: is defined as Scope Resolution Operator. It used when when we want to access constants, properties and methods defined at class level. When referring to these items outside class definition, name of class is used along with scope resolution operator.
This is the so called "splat" operator. Basically that thing translates to "any number of arguments"; introduced with PHP 5.6.
Hello @kartik, The @ symbol is the error control operator ("silence" or "shut-up" operator). It makes PHP suppress any error messages (notice, warning, fatal, etc) generated by the associated expression. It works just like a unary operator, for example, it has a precedence and associativity.
$this is a reserved keyword in PHP that refers to the calling object. It is usually the object to which the method belongs, but possibly another object if the method is called statically from the context of a secondary object. This keyword is only applicable to internal methods.
^
is the bitwise exclusive OR operator. For each bit in a value, it looks to see if that bit is the same in the other value; if it is the same, a 0 is output in its place, otherwise a 1 is output. For example:
00001111
^ 01010101
--------
01011010
XOR (exclusive OR):
$a ^ $b means bits that are set in $a or $b, but not both, are set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With