PHP Simple Implementation Subtraction Calculator

Source: Internet
Author: User

  Subtraction Calculator Presumably everyone has used it, this article for you to introduce how to implement the use of PHP, the following has a good example, interested friends can refer to the following

Implement the subtraction calculator in PHP. The code is very simple Oh!   Code as follows: <?php  header ("Content-type:text/html;charset=utf-8");  session_start (); ?>   <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  <html xmlns=" http://www.w3.org/1999/xhtml "xml:lang=" ZH-CN "dir=" ltr ">  <head>  <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>  <title> simple computer </title>  </head>  <body>  <form action= "jisuan.php" method= "POST" >  first number <input type= "text" value= "" Name= "NUM1" ><br/>  calculation symbol <select name= "oper" >  <option value= "+" >+</option>  <option value= "-" >-</ option>  <option value= "*" >*</option>  <option value= "/" >/</option>  < /SELECT><BR/>  The second number <input type= "text" value= "" Name= "num2" ><br "/>  <input" type= "Submit "value=" Results "><br/>  </form>  </body>  </html>  <?php   $num 1=$_post[' num1 '];  $num 2=$_post[' num2 '];  $oper =$_post[' oper '];  $rs =0;  switch ($ OPER) {  case "+":  $rs = $num 1+ $num 2;  break;  Case "-":  $rs = $num 1-$num 2;  break;  Case "*":  $rs = $num 1* $num 2;  break;  case "/":  $rs = $num 1/$num 2;  break; -Default:echo " You have entered an incorrect "; }  $_session[' rs ']= $rs;  Echo ' evaluates to: '. $_session[' rs ']; ?> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.