All Operators Of PHP

 

All PHP Operators

 An expression is the basic building block of the language.
Anything with a value can be thought of as an expression. Examples include:

5
5+5
$a
$a==5
sqrt(9)
By combining many of these basic expressions, you can build larger, more complex expressions.

Note that the echo statement we've used in numerous examples cannot be part of a complex expression because it does not have a return value. The print statement, on the other hand, can be used as part of complex expression -- it does have a return value. In all other respects, echo and print are identical: they output data.




Expressions are combined and manipulated using operators. The following table lists the operators from highest to lowest precedence; the second column (A) shows the operators' associativity. These operators should be familiar to you if you have any C, Java, or Perl experience.

Operators
A
!, ~, ++, --, @, (the casting operators)
Right
*, /, %
Left
+, -, .
Left
<<, >>
Left
<, <=, >=, >
Nonassociative
==, !=, ===, !==
Nonassociative
&
Left
^
Left
|
Left
&&
Left
||
Left
? : (conditional operator)
Left
=, +=, -=, *=, /=, %=, ^=, .=, &=, |=, <<=, >>=
Left
AND
Left
XOR
Left
OR
Left