Operators
Using variables is nice, but if we cannot make them interact with each other, there is nothing much we can do. Operators are elements that take some expressions—operands—and perform actions on them to get a result. The most common examples of operators are arithmetic operators, which you already saw previously.
An expression is almost anything that has a value. Variables, numbers, or text are examples of expressions, but you will see that they can get way more complicated. Operators expect expressions of a specific type, for example, arithmetic operators expect either integers or floats. But as you already know, PHP takes care of transforming the types of the expressions given whenever possible.
Let's take a look at the most important groups of operators.
Arithmetic operators
Arithmetic operators are very intuitive, as you already know. Addition, subtraction, multiplication, and division (+
, -
, *
, and /
) do as their names say. Modulus (%
) gives the remainder of the division of two...