Home > php教程 > PHP源码 > body text

一个简单的在线计算器

PHP中文网
Release: 2016-05-25 17:08:25
Original
2157 people have browsed it

php代码


	
		
		一个简单的计算器
	
第一个操作数不能为空"; unset($_POST["sub"]); //取消表单中的提交变量,后面计算判断时将不执行 } if(empty($_POST["num2"])){ //如果第二个第一个操作数为空输出错误信息,并停止计算 echo "第二个操作数不能为空"; unset($_POST["sub"]); //取消表单中的提交变量,后面计算判断时将不执行 } $oper=$_POST["oper"]; //获取操作符号 $num1=$_POST["num1"]; //获取第一个操作数 $num2=$_POST["num2"]; //获取第二个操作数 if($oper == "/"){ if($num2 == 0){ echo "0不能作为除数使用"; unset($_POST["sub"]); } } } ?> "; } ?>

简单的计算器

"; echo "计算结果:$num1 $oper $num2 = $sum"; echo "
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!