PHP Operators
Operators are used to perform operations on variables and values.
PHP divides the operators in the following groups:
- Arithmetic operators
- Assignment operators
- Comparison operators
- Increment/Decrement operators
- Logical operators
- String operators
- Array operators
- Conditional assignment operators
PHP Arithmetic Operators
| + | Addition | $x + $y | Sum of $x and $y |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x + $y;
?>
</body>
</html>
| - | Subtraction | $x - $y | Difference of $x and $y |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x - $y;
?>
</body>
</html>
| * | Multiplication | $x * $y | Product of $x and $y |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x * $y;
?>
</body>
</html>
| / | Division | $x / $y | Quotient of $x and $y |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x / $y;
?>
</body>
</html>
| % | Modulus | $x % $y | Remainder of $x divided by $y |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x % $y;
?>
</body>
</html>
| ** | Exponentiation | $x ** $y | Result of raising $x to the $y'th power |
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 3;
echo $x ** $y;
?>
</body>
</html>
Comments
Post a Comment