Introduction to Operators
Explore PHP operators used for performing operations like addition, comparison, logic, and assignment. Understand how these symbols work on values and expressions to produce results, setting a foundation for writing efficient PHP code.
We'll cover the following...
What is a PHP Operator?
A PHP operator is a symbol that performs an operation on one or more values. In PHP, operators are used to carry out tasks such as addition, comparison, assignment, and logical evaluation. An operator takes one or more values or expressions and produces another value. For example, when you add 2 and 5, the result is 7, so the expression 2 + 5 evaluates to 7.
Types of Operators
There are multiple types of operators for various purposes, i.e.,
- arithmetic operators
- comparison operators
- logical operators
- assignment operators
The following figure illustrates the various kinds of operators in PHP:
If you are new to the type of operators, don’t fret. In the next few lessons, we will look at each type in more detail.