Home  >  Article  >  Backend Development  >  PHP implements online calculator function

PHP implements online calculator function

墨辰丷
墨辰丷Original
2018-05-18 16:23:011509browse

This article mainly introduces the simple online calculator function implemented in PHP, involving skills related to PHP numerical operations and form operations. Friends in need can refer to it

The details are as follows:




简单的计算器(www.jb51.net)

第一个操作数不能为空"; 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 "

Related recommendations:

PHP implementationOnline calculation Detailed explanation of the tool function sample code

Use php mysql to make a powerful Online calculation device_PHP tutorial

##phpOnline calculation device Implementation

The above is the detailed content of PHP implements online calculator function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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