Course Content
State Management
0/1
Regular Expressions?
0/1
About Lesson

Example of operators:

1.Arithmetic Operators:

PHP
$a = 5;

       $b = 2;

       $sum = $a + $b;      // 7

       $difference = $a - $b; // 3

       $product = $a * $b;   // 10

       $quotient = $a / $b;  // 2.5

       $remainder = $a % $b; // 1

2.Comparison Operators:

PHP
$x = 10;

         $y = 5;

         $result1 = ($x == $y);  // false

         $result2 = ($x != $y);  // true

         $result3 = ($x < $y);   // false

         $result4 = ($x > $y);   // true

         $result5 = ($x <= $y);  // false

         $result6 = ($x >= $y);  // true

3.Logical Operators:

PHP
$isTrue = true;

         $isFalse = false;

         $result7 = ($isTrue&& $isFalse); // false

         $result8 = ($isTrue || $isFalse); // true

         $result9 = !$isTrue;              // false

4.Assignment Operators:

PHP
$number = 10;

         $number += 5;  // $number is now 15

          $number -= 3;  // $number is now 12

          $number *= 2;  // $number is now 24

          $number /= 4;  // $number is now 6

5.Increment/Decrement Operators:

PHP
$count = 5;

         $count++; // Increment by 1, $count is now 6

          $count--; // Decrement by 1, $count is now 5