Expressions and Operators in php

An expression is a bit of PHP that can be evaluated to produce a value. The simplest expressions are literal values and variables. A literal value evaluates to itself, while a variable evaluates to the value stored in the variable. More complex expressions can be formed using simple expressions and operators

An operator takes some values (the operands) and does something (for instance, adds them together). Operators are written as punctuation symbols—for instance, the + and – familiar to us from math. Some operators modify their operands, while most do not

The column labeled “P” gives the operator’s precedence; the operators are listed in precedence order, from highest to lowest. The column labeled “A” gives the operator’s associativity, which can be L (left-to-right), R (right-to-left), or N (nonassociative).

List of PHP operators

PAOperatorOperation
21Nclone, newCreate new object
20L[Array subscript
19R~Bitwise NOT
R++Increment
R−−Decrement
R(int), (bool), (float), (string), (array), (object),
(unset)
Cast
R@Inhibit errors
18NinstanceofType testing
17R!Logical NOT
16L*Multiplication
L/Division
L%Modulus
15L+Addition
LSubtraction
L.String concatenation
14L<<Bitwise shift left
L>>Bitwise shift right
13N<, <=Less than, less than or equal
N, >=Greater than, greater than or equa
12N==Value equality
N!=, <>Inequality
N===Type and value equality
N!==Type and value inequality
11L&Bitwise AND
10L^Bitwise XOR
9L|Bitwise OR
8L&&Logical AND
7L||Logical OR
6L?:Conditional operator
5L=Assignment
L+=, −=, *=, /=, .=, %=, &=, |=, ^=, ~=, <<=, >>=Assignment with operation
4LandLogical AND
3LxorLogical XOR
2LorLogical OR
1L,List separator
List of PHP operators

Leave a Comment