查看: 5868|回复: 0
打印 上一主题 下一主题

用php做的计算器,大家看看..

[复制链接]
跳转到指定楼层
1#
发表于 2007-10-5 11:27:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
<html>
        <head>
                <title></title>
                <meta content="text/html charset=gb2312">
               
        </head>
        <body>
                <?php
                        $no1=$_GET['no1'];
                        $no2=$_GET['no2'];
                        $no3=$_GET['no3'];

                        //global $num;
                        $a = $_GET['1'];
                        $a = $a.$_GET['2'];
                        $a = $a.$_GET['3'];
                        $a = $a.$_GET['4'];
                        $a = $a.$_GET['5'];
                        $a = $a.$_GET['6'];
                        $a = $a.$_GET['7'];
                        $a = $a.$_GET['8'];
                        $a = $a.$_GET['9'];
                        
                        if((int)$a>0){
                                $num = $_GET['text'];
                                if($no1=="="){
                                        $num = 0;
                                }
                                $numa =(int)$num;
                                if($numa==0){
                                        $num = $a;
                                }else{
                                        $num = $num.$a;
                                }
                        }

                        if($_GET['CE']=="CE"){
                                $num = 0;
                                $no1 = 0;
                                $no2 = 0;
                                $no3 = 0;
                        }
                        
                        //global $fuhao;
                        $fuhao = $_GET['jia'];
                        $fuhao = $fuhao.$_GET['jian'];
                        $fuhao = $fuhao.$_GET['cheng'];
                        $fuhao = $fuhao.$_GET['chu'];

                        //global $num2;
                        if($fuhao=='+'||$fuhao=='-'||$fuhao=='*'||$fuhao=='/'){
                                //global $fuhao1;
                                $no3 = $fuhao;
                                $no1 = $_GET['text'];
                                $num = 0;
                        }
                        
                        //global $num3;

                        if($_GET['dengyu']=="="){
                                $num3 = $_GET['text'];
                                $no1 = (double)$_GET['no1'];
                                $no2 = (double)$num3;
                                $no3 = $_GET['no3'];
                                switch($no3){
                                        case '+':
                                                $num = $no1 + $no2;
                                                break;
                                        case '-':
                                                $num = $no1 - $no2;
                                                break;
                                        case '*':
                                                $num = $no1 * $no2;
                                                break;
                                        case '/':
                                                $num = $no1 / $no2;
                                                break;
                                }
                        }
                ?>
                <form name="" action="" method="get">
                        <table bgcolor="blue" border="10" align="center">
                                <tr align="center">
                                        <td colspan="4">计算器</td>
                                </tr>
                                <tr>
                                        <td colspan="4"><input type="text" name="text" readonly="true" align="right" value=<?php echo $num; ?> ></td>
                                </tr>
                                <tr>
                                        <td><input type="submit" name="1" value="1"></td>
                                        <td><input type="submit" name="2" value="2"></td>
                                        <td><input type="submit" name="3" value="3"></td>
                                        <td><input type="submit" name="jia" value="+"></td>
                                </tr>
                                <tr>
                                        <td><input type="submit" name="4" value="4"></td>
                                        <td><input type="submit" name="5" value="5"></td>
                                        <td><input type="submit" name="6" value="6"></td>
                                        <td><input type="submit" name="jian" value="-"></td>
                                </tr>
                                <tr>
                                        <td><input type="submit" name="7" value="7"></td>
                                        <td><input type="submit" name="8" value="8"></td>
                                        <td><input type="submit" name="9" value="9"></td>
                                        <td><input type="submit" name="cheng" value="*"></td>
                                </tr>
                                <tr>
                                        <td><input type="submit" name="CE" value="CE"></td>
                                        <td><input type="submit" name="0" value="0"></td>
                                        <td><input type="submit" name="dengyu" value="="></td>
                                        <td><input type="submit" name="chu" value="/"></td>
                                </tr>
                                <tr>
                                        <td><input type="hidden" name="no1" value=<?php echo $no1 ?> ></td>
                                        <td><input type="hidden" name="no2" value=<?php echo $no2 ?> ></td>
                                        <td><input type="hidden" name="no3" value=<?php echo $no3 ?> ></td>
                                        <td></td>
                                </tr>
                        </table>
                </form>
        </body>
</html>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表