PHP Operators

PHP Operators

Operators are used to perform operations on variables and values. PHP divides operators into several groups.


1. Arithmetic Operators

The PHP arithmetic operators are used with numeric values to perform common arithmetical operations.

2. Assignment Operators

The basic assignment operator in PHP is =. It means that the left operand gets set to the value of the assignment expression on the right.

3. Comparison Operators

Comparison operators are used to compare two values (number or string):

Comparison Example

<?php
$x = 100;  
$y = "100";

var_dump($x == $y); // returns true because values are equal echo "\n"; var_dump($x === $y); // returns false because types are not equal ?>

4. Logical Operators

Logical operators are used to combine conditional statements: && (And), || (Or), ! (Not).