PHP - Operators and Expressions

Introduction

Using an operator, you can manipulate the contents of one or more variables to produce a new value.

For example, the following code uses the addition operator ( + ) to add the values of $x and $y together to produce a new value:

echo $x + $y;

An operator is a symbol that manipulates one or more values, usually producing a new value.

An expression in PHP is anything that evaluates to a value.

The expression can be any combination of values, variables, operators, and functions.

In the preceding example, $x + $y is an expression.

Here are some more examples of expressions:

$x + $y + $z
$x - $y
$x
5
true
gettype( $test_var )

The values and variables that are used with an operator are known as operands .

Related Topic