Professional Documents
Culture Documents
Answer:
1. Arithmetic Operators:
- Used for basic mathematical operations.
- Example:
<?php
$a = 10;
$b = 5;
$sum = $a + $b; // Addition
$difference = $a - $b; // Subtraction
$product = $a * $b; // Multiplication
$quotient = $a / $b; // Division
$remainder = $a % $b; // Modulus
?>
2. Assignment Operators:
- Used to assign values to variables.
- Example:
<?php
$x = 10;
$y = 5;
$x += $y; // Equivalent to $x = $x + $y;
?>
3. Comparison Operators:
- Used to compare values and return true or false.
- Example:
<?php
$a = 10;
$b = 5;
$isEqual = $a == $b; // Equal to
$isNotEqual = $a != $b; // Not equal to
$isGreater = $a > $b; // Greater than
?>
4. Logical Operators:
- Used to combine and manipulate conditions.
- Example:
<?php
$x = true;
$y = false;
$result = $x && $y; // Logical AND
$result2 = $x || $y; // Logical OR
$result3 = !$x; // Logical NOT
?>
5. Increment/Decrement Operators:
- Used to increase or decrease a variable's value.
- Example:
<?php
$count = 5;
$count++; // Increment by 1
$count--; // Decrement by 1
?>