1. PHP Program to Calculate Addition and Subtraction of two Numbers.
How does this program work?
- In this program you will learn about how to find addtion and subtraction of two numbers using PHP.
- Initially The integer entered by the user is stored in two variables a,b.
- After that by using the given formula you will get output.
Here is the code
<html>
<head>
<title>PHP Program for Addition and Subtraction of two numbers</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter a value"/></td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter b value"/></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$a = $_POST['num1'];
$b = $_POST['num2'];
$sum = $a + $b; // Addition of two numbers
$diff = $a - $b;// Subtraction of two numbers
echo "Addition = ".$sum;
echo "Subtraction = ".$diff;
return 0;
}
?>
</body>
</html>