利用PHP和Html + javascript 编写一个简单的网页计算器程序,可以根据这种有趣的开发构架出更加有趣的网页。
​1. [代码]PHP计算器    
<html>
<head>
<title>caculator</title>
</head>
 
<body>
<form name="myform" method="POST">
<tr>
<script language = "javascript">
</script>
<td><input type="text" name="text1"/></td><br/>
<td><input type="text" name="sign" value="+"/<?$_GET['add']?></td><br/>
<td><input type="text" name="text2"/></td><br/>
<td><input type="text" name="text3"/></td><br/>
<td><input type="button" name="count" value="="/></td><br/>
<td><input type="text" name="equals"/></td><br/>
<td><input type="reset" name="reset"/></td><br/>
</tr>
<tr>
<script language = "javascript">
function count(text3){
    var text1 = parseint(document.form.text1.value);
    var text2 = parseint(document.form.text2.value);
}
switch(text3){
    case 0:
        document.form.text3.value = text1 + text2;
        break;
        case 1:
            document.form.text3.value = text1 - text2;
            break;
        case 2:
            document.form.text3.value = text1 * text2;
            break;
        case 3:
            document.form.text3.value = text1 / text2;
            break;
            default(text3 = text1/text2!=0){
                document.form.text3.value = text1/text2;
            }
}
</script>
<td><input type="text" name="text1"/></td><br/>
<td><input type="text" name="sign" value="-"/><?$_GET['sub']?></td><br/>
<td><input type="text" name="text2"/></td><br/>
<td><input type="text" name="text3"/></td><br/>
<td><input type="button" name="count" value="="/></td><br/>
<td><input type="text" name="equals"/></td><br/>
<td><input type="reset" name="reset"/></td><br/>
</tr>http://www.huiyi8.com/hunsha/​
<tr>婚纱摄影
<script language = "javascript">
</script>
<td><input type="text" name="text1"/></td><br/>
<td><input type="text" name="sign" value="*"/><?$_GET['mul']?></td><br/>
<td><input type="text" name="text2"/></td><br/>
<td><input type="text" name="text3"/></td><br/>
<td><input type="button" name="count" value="="/></td><br/>
<td><input type="text" name="equals"/></td><br/>
<td><input type="reset" name="reset"/></td><br/>
</tr>
<tr>
<script language = "javascript">
</script>
<td><input type="text" name="text1"/></td><br/>
<td><input type="text" name="sign" value="/"/><?$_GET['div']?></td><br/>
<td><input type="text" name="text2"/></td><br/>
<td><input type="text" name="text3"/></td><br/>
<td><input type="button" name="count" value="="/></td><br/>
<td><input type="text" name="equals"/></td><br/>
<td><input type="reset" name="reset"/></td><br/>
</tr>
</form>
<?php
class calculate{
    pbulic $text1;
    public $text2;
    public $text3;
    function add($text1,$text2){
        $text3 = $text1 + $text2;
        $this->text1=$text1;
        $this->text2=$text2;
        echo "$_GET[add]";
    }
        function sub($text1,$text2){
        $text3 = $text1 - $text2;
        $this->text1=$text1;
        $this->text2=$text2;
        echo "$_GET[sub]";
        }
            function mul($text1,$text2){
        $text3 = $text1 * $text2;
        $this->text1=$text1;
        $this->text2=$text2;
        echo "$_GET[mul]";
        }
        function div($text1,$text2){
        $text3 = $text1 / $text2;
        $this->text1=$text1;
        $this->text2=$text2;
        echo "$_GET[div]";
        }
        function getresult(){
        echo $text3 = ($text1 + $text2). ".$_GET[add]";
        echo $text3 = ($text1 + $text2). ".$_GET[sub]";
        echo $text3 = ($text1 + $text2). ".$_GET[mul]";
        echo $text3 = ($text1 + $text2). ".$_GET[div]";
        }
 
}
?>
</body>
</html>
​

PHP编写网页BS结构计算器的更多相关文章

  1. .Net机试题——编写一个BS架构的多层表结构的信息管理模块

      要求: 编写一个BS架构的多层表结构的信息管理模块,用户体验需要注意.包含错误处理,需要最终能完整的跑起来.页面可以不美化,但是整洁还是必须的.在不能完成详细功能需求的情况下优先保证基本功能. 1 ...

  2. seo之google rich-snippets丰富网页摘要结构化数据(微数据)实例代码

    seo之google rich-snippets丰富网页摘要结构化数据(微数据)实例代码 网页摘要是搜索引擎搜索结果下的几行字,用户能通过网页摘要迅速了解到网页的大概内容,传统的摘要是纯文字摘要,而结 ...

  3. Java和.Net在做BS结构项目的比较

    渊源: Java的J2EE在1999年形成了其成熟的架构,并且到今天已经有相当成熟的经过检验的企业应用系统.而.Net究其渊源是源自微软以前开发企业应用程序的平台DNA(DistributedNetw ...

  4. 深入理解BS结构应用程序

    随着学习的深入,和编程经验的丰富,对BS应用程序有一些认识. 在一些讨论软件技术的QQ群里,或一些社区.BBS中,经常会有一些初学者会犯一些认知性的错误.比如经常会有一些朋友提这样的一些问题:“我怎么 ...

  5. html网页基本结构

    <!DOCTYPE> 不是 HTML 标签.它为浏览器提供一项信息(声明),即 HTML 是用什么版本编写的. HTML5 DOCTYPE 的 HTML 文档类型如下: <!DOCT ...

  6. 什么是CS和BS结构,两种结构的区别

    什么是CS和BS结构,两种结构的区别 什么是C/S和B/S结构?         C/S又称Client/Server或客户/服务器模式.服务器通常采用高性能的PC.工作站或小型机,并采用大型数据库系 ...

  7. 如何:使用 Visual Basic 编写基于 Unity3D 的计算器

    随着 .NET 全平台战略的推进,微软正在让以 C# 为先锋的 .NET 拥有跨平台特性.这个过程中一直有人想知道其它 .NET 语言对跨平台的支持有什么改进,熟悉 C# 但是喜欢用 VB 的我也不例 ...

  8. 1.cs与bs结构

    ####CS 与 BS 结构 C/S 结构软件:客户端(Client)服务器(Server)软件,客户端需要单独下载安装之后,才能正常操作的软件 B/S 结构软件:浏览器(Browser)服务器(Se ...

  9. 网络应用软件结构-----CS与BS结构(网络基本知识小结)

    1.网络的大致结构 2.网络编程 通过直接或间接地使用网络通讯的协议实现计算机与计算机之间的通讯.在TCP/IP协议层主要麦网络主机的定位,数据传输的路由,由IP地址可以唯一地确定Internet上的 ...

随机推荐

  1. Java 8 Streams的简单使用方法

    Java 8 Streams的简单使用方法 package JDK8Test; import java.util.ArrayList; public class Main { public stati ...

  2. GeoServer自动发布地图服务

    1 NetCDF气象文件自动发布案例 GeoServer是一个地理服务器,提供了管理页面进行服务发布,样式,切片,图层预览等一系列操作,但是手动进行页面配置有时并不满足业务需求,所以GeoServer ...

  3. Cesium热力图实现

    转自原文 Cesium热力图实现 生成热力图的算法我是用的一个热力图插件 heatmap.js.   heatmap中热力图生成原理: heatmap中首先会根据输入的渐进色参数,在内部生成一个0-2 ...

  4. SQL-基础学习使用的数据库资料

    -- ------------------------ Create Customers table-- ----------------------CREATE TABLE Customers( c ...

  5. VS中的 MD/MT设置 【转】

    VS系列工具作为目前微软主打的集成开发环境,在历经了近20多年的发展后,到如今已经可以 说是Windows平台上各种IDE环境中的翘楚了.很多别的开发工具已经难望其项背了,如今VS2010也已经面市很 ...

  6. 每天一个 Linux 命令(16):which whereis locate命令

    which  查看可执行文件的位置. whereis 查看文件的位置. locate   配合数据库查看文件位置.#whereis 和locate是从文件数据库里查找 数据库默认一个星期更新一次,所有 ...

  7. LoadRunner多负载产生器

    Executive Summary : The following explains why it is necessary to have about 6 load generators when ...

  8. 设置安卓开机动画、开机logo

    我们要修改的是system>media文件夹下的bootanimation.zip(手机开机动画)这个文件 先来讲讲这个文件结构:该zip解压后得到两个文件, 第一个目录存放了开机时播放的图片( ...

  9. python(18)- 协程函数及应用

    协程 def init(func): def wrapper(*args,**kwargs): obj = func(*args,**kwargs) next(obj) return obj retu ...

  10. (updated on Mar 1th)Programming Mobile Applications for Android Handheld Systems by Dr. Adam Porter

    本作品由Man_华创作,采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可.基于http://www.cnblogs.com/manhua/上的作品创作. Lab - Inte ...