PHP operators are essentially the same as the JavaScript operators we have already looked at.

Arithmetic Operators

Operator Description
+
Unary plus, or addition.
-
Unary minus or subtraction.
/
Division.
*
Multiplication.
%
Modulus (remainder from a divide operation).
++
Increment (pre-increment if placed before the variable, post-increment if placed after).
--
Decrement (pre-decrement if placed before the variable, post-decrement if placed after).


If an assignment is made that requires the value of the variable being assigned to, PHP offers a convenient shortcut by placing the operator immediately before the assignment operator.

$total += $a; // Equivalent to $total = $total + $a;
$difference -= $a; // Equivalent to $difference = $difference - $a;
$product *= $a; // Equivalent to $product = $product * $a;
$quotient /= $a; // Equivalent to $quotient = $quotient / $a;
$remainder %= $a; // Equivalent to $remainder = $remainder % $a;Relational Operators

Relational Operators

Relational operators (sometimes called comparison operators) are used to compare values in an expression. The return value will be either true or false.

Operator
Description
<
Less than (eg. $x < 10).
<=
Less than or equal (eg. $x <= 10).
==
Equivalence (eg. $x == 10).
>
Greater than (eg. $x > 10).
>=
Greater than or equal (eg. $x >= 10).
!=
Not equivalent (eg. $x != 10).

Logical Operator

Logical operators allow you to combine the results of multiple expressions to return a single value that evaluates to either true or false.

PHP Logical Operators Operator Description
! Logical Not. For example, (!$x) will evaluate to True if $x is zero.
&& Logical And. For example, ($x > 4 && $y <= 10) will evaluate to True is $x is greater than four and $y is less than or equal to ten.

|| Logical Or. For example, ($x > 10 || $y > 10) will evaluate to True is either $x or $y are greater than ten.

(from juicystudio.com)

If

Table of Contents