P A Operator Operation
19NnewCreate new object
18R[ Array subscript
17R! Logical NOT
R~ Bitwise NOT
The bitwise negation operator changes 1s to 0s and 0s to 1s in the binary representations of the operands.
R++ Increment
R-- Decrement
R(int)
(double)
(string)
(array)
(object)
Cast
R@ Inhibit errors
16L* Multiplication
L/ Division
L% Modulus
15L+ Addition
L- Subtraction
L. String concatenation
14L<<Bitwise shift left
Shifts the bits in the binary representation of the lefthand operand left by the number of places given in the righthand operand.
L>>Bitwise shift right
Shifts the bits in the binary representation of the lefthand operand right by the number of places given in the righthand operand.
13N<,<=Less than, less than or equal to
N>,>=Greater than, greater than or equal to
12N== Value equality
If both operands are equal, this operator returns true; otherwise, it returns false.
N!=,<>Inequality
If both operands are not equal, this operator returns true; otherwise, it returns false.
N===Type and value equality
If both operands are equal and are of the same type, this operator returns true; otherwise, it returns false.
N!==Type and value inequality
If both operands are not equal, or they are not of the same type, this operator returns true; otherwise, it returns false.
11L&Bitwise AND
Compares each corresponding bit in the binary representations of the operands. If both bits are 1, the corresponding bit in the result is 1; otherwise, the corresponding bit is 0.
10L^ Bitwise XOR
Compares each corresponding bit in the binary representations of the operands. If either of the bits in the pair, but not both, is 1, the corresponding bit in the result is 1; otherwise, the corresponding bit is 0.
9L| Bitwise OR
Compares each corresponding bit in the binary representations of the operands. If both bits are 0, the corresponding bit in the result is 0; otherwise, the corresponding bit is 1.
8L&&Logical AND
Evaluates to true if and only if both operands are true; otherwise, it is false.
7L|| Logical OR
Evaluates to true if either operand is true; otherwise, it is false.
6L?: Conditional operator
PHP's only ternary (three-operand) operator and is therefore sometimes just called the ternary operator. It evaluates the expression before the ?. If the expression is true, the operator returns the value of the expression between the ? and the :; otherwise, the operator returns the value of the expression after the :
$reply = ( $in == 'yes' ) ? 'Great' : 'Too bad' ;
This is functionally equivalent to:
if ( $in == 'yes' ) {
	$reply = 'Great' ;
} else {
	$reply = 'Too bad' ;
}
5L= Assignment
L+=, -=, *=, /=, .=, %=, &=, |=, ^=, ~=, <<=, >>=Assignment with operation
$x += $y ;
$j .= $k
are the same as:
$x = $x + $y ;
$j = $j . $k ;
4LandLogical AND
Evaluates to true if and only if both operands are true; otherwise, it is false. The and operator differs from the && operator only in precedence.
3LxorLogical XOR
Evaluates to true if either operand but not both, is true; otherwise, it is false.
2Lor Logical OR
Evaluates to true if either operand is true; otherwise, it is false. The or operator differs from the || operator only in precedence.
1L, List seperator

Return to Previous Page