PHP Fundamentals

Learn PHP programming from scratch, including variables, functions, arrays, and object-oriented programming.

beginner Backend Development 6 hours

Chapter 5: Operators and Expressions

Chapter 5 of 15

Chapter 5: Operators and Expressions

5.1 Arithmetic Operators

$sum = 10 + 5;      // Addition
$diff = 10 - 5;     // Subtraction
$product = 10 * 5;  // Multiplication
$quotient = 10 / 5; // Division
$modulus = 10 % 3;  // Modulus (remainder)

5.2 Comparison Operators

$a == $b   // Equal (value)
$a === $b  // Identical (value and type)
$a != $b   // Not equal
$a !== $b  // Not identical
$a < $b    // Less than
$a > $b    // Greater than

5.3 Logical Operators

$a && $b   // AND
$a || $b   // OR
!$a        // NOT