PHP is open source scripting language. It\'s widely used to develop web applications.  Home Web Programming PHP PHP Calculator
Your Ad Here

PHP Calculator


PHP CalculatorThis tutorial will teach you how to make a calculator using PHP.

Firstly, create a new .php document and copy/paste the following code into it.

<?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 } ?>

Legend:

* Multiply
- Subtract
/ Divide
+ Add



Author's URL: Cable
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Web programming � everything from the basics of visual design and architecture to the specifics of applications, graphics, and scripting. More Web Programming: Most Popular Materials | Fresh Materials | More PHP Tutorials at LearnPHP.org

Add comments to "PHP Calculator"

Only registered users can write comment

No comments yet...