From the below Example We will Get To Know some basic examples of Operators
<?php
$num1 = 10;
$num2 = 5;
// Addition
$result = $num1 + $num2;
echo $result . "\n"; // Output: 15
// Subtraction
$result = $num1 - $num2;
echo $result . "\n"; // Output: 5
// Multiplication
$result = $num1 * $num2;
echo $result . "\n"; // Output: 50
// Division
$result = $num1 / $num2;
echo $result . "\n"; // Output: 2
// Modulus
$result = $num1 % $num2;
echo $result . "\n"; // Output: 0
// Exponential
$result = $num1 ** $num2;
echo $result . "\n"; // Output: 100000
?>
In this example, we first declare two variables $num1 and $num2 and assign them values. Then we perform various arithmetic operations using the arithmetic operators and store the result in the $result variable. Finally, we use the echo statement to print the result to the screen.
Comments
Post a Comment