snippet library logo
The Best Html Forum Around
in category
PHP / Misc / Simple Calculator
Snippet details
ID: 518
Viewed: 1669
Added: 2003-11-03
Version: 1.0
Sorry no demo

User Rated at:
Rate This:
Snippets in this catagory         
Show Printable Version
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


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Subject:

Reviewed By:

Write a review:





Terms of Conditions
Powered By
Avian Hosting
© 2005 snippetlibrary.com All Rights Reserved.