Snippet details
ID: 518
Viewed: 1669
Added: 2003-11-03
Version: 1.0
Sorry no demo
A simple calculator written in PHP. Later versions will include more operators.
General Details
Snippet uploaded by: Martyn Coupland
Email : webmaster@windowsforums.net
Snippet By: DA Master
<!---Head--->
The first box is the first number to calculate, the second is the operator (* / + -) and the third is the second number.
<!---Body--->
<?php
/* Calculator */
if($submit)
{
if($operator == '*')
{
echo $numa * $numb;
} elseif($operator == '/')
{
echo $numa / $numb;
} elseif($operator == '+')
{
echo $numa + $numb;
} elseif($operator == '-')
{
echo $numa - $numb;
}
} else { ?>
<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="text" name="numa" size="10">
<input type="text" name="operator" size="2">
<input type="text" name="numb" size="10">
<input type="submit" value="Calculate" name="submit">
</form>
<?php } ?>
No Reviews to show
