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
familiar to us from math. Some operators modify their operands, while most
Table 2-3 summarizes the operators in PHP, many of which were borrowed from C and Perl. 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).
Table 2-3. PHP operators
Create new object
Bitwise shift left
Bitwise shift right
Less than, less than or equal
Greater than, greater than or equal
Type and value equality
Type and value inequality