Algorithm
Using Simple Arithematic expression
- Summation:
$a + $b
- Subtraction:
$a - $b
- Multiplication:
$a * $b
- Division:
$a / $b
Code Examples
#1 PHP Summation Example
Code -
PHP Programming
<?php
$a = 1;
$b = 2;
$sum = $a + $b;
echo $sum; // 3
?>
Copy The Code &
Try With Live Editor
Output
3
#2 PHP Subtraction Example
Code -
PHP Programming
<?php
$a = 10;
$b = 20;
$sub = $b - $a;
echo $sub; // 10
?>
Copy The Code &
Try With Live Editor
Output
10
#3 PHP Multiplication Example
Code -
PHP Programming
<?php
$a = 10;
$b = 20;
$mul = $a * $b;
echo $mul; // 200
?>
Copy The Code &
Try With Live Editor
Output
200
#4 PHP Division Example
Code -
PHP Programming
<?php
$a = 10;
$b = 20;
$div = $b / $a;
echo $div; // 2
?>
Copy The Code &
Try With Live Editor
Output
2
Demonstration
PHP Simple Summation, Subtraction, Multiplication, Division Example in PHP