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上的 ...
随机推荐
- HDU - 3664 Permutation Counting
Discription Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of ...
- layui-时间选择器-时间范围选择
HTML: JS: layui.use(['laydate'],function{ }); start:就为你选择的开始日期; end:就为你选择的结束日期 此方式可选择任意范围的时间,时间格式可任意 ...
- 安装Vmware增强工具
主机: Win7 虚拟机: VMware8.0+Debian6 目标: 离线安装软件包和VMware Tools 在虚拟机上安装完debian6后 1.在vmware的菜单中选择Vm->inst ...
- Linux有问必答:如何检查Linux的内存使用状况
-1. /proc/meminfo11% -2. atop20% -3. free29% -4. GNOME System Monitor35% -5. htop41% -6. KDE System ...
- Python爬虫之路——简单网页抓图升级版(添加多线程支持)
转载自我的博客:http://www.mylonly.com/archives/1418.html 经过两个晚上的奋斗.将上一篇文章介绍的爬虫略微改进了下(Python爬虫之路--简单网页抓图),主要 ...
- 并行程序设计---cuda memory
CUDA存储器模型: GPU片内:register,shared memory: host 内存: host memory, pinned memory. 板载显存:local memory,cons ...
- 使用Lua 局部变量来优化性能,同一时候比較局部变量和全局变量
在竞争激烈的游戏行业中,尤其页游,面对策划复杂和频繁的需求,使用脚本能够减少难度和成本.在使用Lua的过程中,会常常訪问全局变量来作为配置文件. 在訪问全局变量时,能够通过局部变量引用全局变量来优化. ...
- 如何下载合适自己系统环境的Xdebug
访问https://xdebug.org 在浏览器输入http://localhost/?phpinfo=1 (前提已经安装了wamp环境) Ctrl+a 全选 ,复制 粘贴到刚才的网站的 ...
- Solaris 目录与文件管理
熟悉系统目录结构 掌握27个常用命令 掌握针对目录.文件的操作 掌握查找与文件内容的操作 一.命令 命令:内部命令(不依赖其他文件,可以直接执行)与外部命令 .他是用于实现某一类功能的指令或程序,其执 ...
- 增加录像时间戳水印、 camera框架介绍
http://blog.csdn.net/mirkerson/article/details/38920107 http://blog.csdn.net/jimbo_lee/article/detai ...