PHP编写网页BS结构计算器
利用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结构计算器的更多相关文章
- .Net机试题——编写一个BS架构的多层表结构的信息管理模块
要求: 编写一个BS架构的多层表结构的信息管理模块,用户体验需要注意.包含错误处理,需要最终能完整的跑起来.页面可以不美化,但是整洁还是必须的.在不能完成详细功能需求的情况下优先保证基本功能. 1 ...
- seo之google rich-snippets丰富网页摘要结构化数据(微数据)实例代码
seo之google rich-snippets丰富网页摘要结构化数据(微数据)实例代码 网页摘要是搜索引擎搜索结果下的几行字,用户能通过网页摘要迅速了解到网页的大概内容,传统的摘要是纯文字摘要,而结 ...
- Java和.Net在做BS结构项目的比较
渊源: Java的J2EE在1999年形成了其成熟的架构,并且到今天已经有相当成熟的经过检验的企业应用系统.而.Net究其渊源是源自微软以前开发企业应用程序的平台DNA(DistributedNetw ...
- 深入理解BS结构应用程序
随着学习的深入,和编程经验的丰富,对BS应用程序有一些认识. 在一些讨论软件技术的QQ群里,或一些社区.BBS中,经常会有一些初学者会犯一些认知性的错误.比如经常会有一些朋友提这样的一些问题:“我怎么 ...
- html网页基本结构
<!DOCTYPE> 不是 HTML 标签.它为浏览器提供一项信息(声明),即 HTML 是用什么版本编写的. HTML5 DOCTYPE 的 HTML 文档类型如下: <!DOCT ...
- 什么是CS和BS结构,两种结构的区别
什么是CS和BS结构,两种结构的区别 什么是C/S和B/S结构? C/S又称Client/Server或客户/服务器模式.服务器通常采用高性能的PC.工作站或小型机,并采用大型数据库系 ...
- 如何:使用 Visual Basic 编写基于 Unity3D 的计算器
随着 .NET 全平台战略的推进,微软正在让以 C# 为先锋的 .NET 拥有跨平台特性.这个过程中一直有人想知道其它 .NET 语言对跨平台的支持有什么改进,熟悉 C# 但是喜欢用 VB 的我也不例 ...
- 1.cs与bs结构
####CS 与 BS 结构 C/S 结构软件:客户端(Client)服务器(Server)软件,客户端需要单独下载安装之后,才能正常操作的软件 B/S 结构软件:浏览器(Browser)服务器(Se ...
- 网络应用软件结构-----CS与BS结构(网络基本知识小结)
1.网络的大致结构 2.网络编程 通过直接或间接地使用网络通讯的协议实现计算机与计算机之间的通讯.在TCP/IP协议层主要麦网络主机的定位,数据传输的路由,由IP地址可以唯一地确定Internet上的 ...
随机推荐
- 3.4 熟练掌握动态规划——状态压缩DP
从旅行商问题说起—— 给定一个图,n个节点(n<=15),求从a节点出发,经历每个节点仅一次,最后回到a,需要的最短时间. 分析: 设定状态S代表当前已经走过的城市的集合,显然,S<=(1 ...
- Flex 布局教程学习
转载自:阮一峰的网络日志(http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html) 网页布局(layout)是 CSS 的一个重点应用. 布局 ...
- FastDFS 使用经验分享
原文:http://www.ttlsa.com/fastdfs/fastdfs-experience-sharing/ 应用背景 文件被上传到FastDFS后Storage服务端将返回的文件索引(FI ...
- win7阻止iis开机启动
https://zhidao.baidu.com/question/111234812.html 1.在"开始/运行/" 输入"services.msc" 启动 ...
- 网页Tab控件
网页Tab控件 找到:http://www.open-open.com/ajax/2_Tabs.htm 页面,查看了若干Tab控件, 找到了:http://www.open-open.com/ajax ...
- C#向Sql数据库插入空值的控制
string name = textBox1.Text; int age = Convert.ToInt32(textBox2.Text.Trim()); ? null : (int?)Convert ...
- discuz X3.1+Apache2.2+php-5.2.17+mysql5.6.14+Discuz_X3.1
discuz X3.1+Apache2.2.25+php-5.2.17+mysql5.6.14+Discuz_X3.1 一.准备 1.httpd-2.2.25-win32-x86-no_ssl.msi ...
- HashSet中存方用户自己定义数据类型数据,重写equals方法和hashCode方法
import java.util.Set; import java.util.HashSet; public class SetTest { public static void main(Strin ...
- 实战c++中的string系列--十六进制的字符串转为十六进制的整型(一般是颜色代码使用)
非常久没有写关于string的博客了.由于写的差点儿相同了.可是近期又与string打交道,于是荷尔蒙上脑,小蝌蚪躁动. 在程序中,假设用到了颜色代码,一般都是十六进制的,即hex. 可是server ...
- 深入struts2.0(七)--ActionInvocation接口以及3DefaultActionInvocation类
1.1.1 ActionInvocation类 ActionInvocation定义为一个接口.主要作用是表现action的运行状态.它拥有拦截器和action的实例.通过重复的运行inv ...