PHP Operators

What is a PHP Operator?

PHP operators perform mathematics operations on variables, manipulation of strings, and comparison of data types and logical operations like (and, or, etc.).

PHP Operators take different numbers of operands. Binary operators take two expressions and produce a single expression, while Unary operators take one operand.

Binary operators, like * and /, take two arguments placed on the left and right sides of the operator, and Unary operators have just one argument placed on the operator's right side or left side.

The pre-increment and pre-decrement operators are Unary operators. A ternary operator that is shorthand for the if statement takes three operands.

Let us take an expression that is 3 x 5 equals to15. Here 3 and 5 are called operands(an operand is an object on which a particular operation takes place), and x, a multiplication sign, is called an operator.

Types of Operators in PHP:-

PHP supports many different types of operators:-

  1. Arithmetic Operators
  2. Assignment Operators
  3. Logical Operators
  4. Comparison Operators
  5. Conditional Operators