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 ']; ?>