home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / Calculator.php < prev    next >
Encoding:
PHP Script  |  2001-07-02  |  1.2 KB  |  41 lines

  1. //**************************************
  2.     //     
  3.     // Name: Calculator
  4.     // Description:A Calculator with four ba
  5.     //     sic functions. by Derian Conteh-Morgan.
  6.     // By: PHP Code Exchange
  7.     //**************************************
  8.     //     
  9.     
  10.     form action=" <? echo $PHP_SELF ?>" method="post">
  11.     1st number:<input type=text name=num1><br>
  12.     2nd number:<input type=text name=num2><br>
  13.     <p>
  14.     What operation would you like to perform?<br>
  15.     <input type=radio name=operation value="plus" checked>Add<br>
  16.     <input type=radio name=operation value="minus">Subtract<br>
  17.     <input type=radio name=operation value="X">Multiply<br>
  18.     <input type=radio name=operation value="divided by">Divide<br>
  19.     <input type=submit><input type=reset>
  20.     </form>
  21.     </body>
  22.     </html>
  23.     The answer to<? echo $num1;?><?echo $operation;?><? echo $num2;?>
  24.     is:<br>
  25.     <h1>
  26.     <?php
  27.     if ($operation == "plus")
  28.     {$x = $num1 + $num2;
  29.     print $x;}
  30.     elseif ($operation == "minus")
  31.     {$x = $num1 - $num2;
  32.     print $x;}
  33.     elseif ($operation == "X")
  34.     {$x = $num1 * $num2;
  35.     print $x;}
  36.     else
  37.     {$x = $num1 / $num2;
  38.     print $x;}
  39.     ?>
  40.     </h1>
  41.