简单计算器
php代码
<html> <head> <title> PHP实现简单计算器 </title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head> <?php if(isset($_GET["sub"])){ $sum=0; $num1=true; $num2=true; $numa=true; $numb=true; $message=""; if($_GET["num1"]==""){ $num1=false; $message="第一个参数为空"; } if($_GET["num2"]==""){ $num2=false; $message="第二个参数为空"; } if(!is_numeric($_GET["num1"])){ $numa=false; $message.="第一个参数不是数字!"; } if(!is_numeric($_GET["num2"])){ $numb=false; $message.="第二个参数不是数字!"; } if($num1 && $num2 && $numa){ switch($_GET["ysf"]){ case "+":$sum=$_GET["num1"]+$_GET["num2"]; break; case "-":$sum=$_GET["num1"]-$_GET["num2"]; break; case "*":$sum=$_GET["num1"]*$_GET["num2"]; break; case "/":$sum=$_GET["num1"]/$_GET["num2"]; break; case "%":$sum=$_GET["num1"]%$_GET["num2"]; break; } } } ?> <body> <table align="center" border="1" width="500"> <caption><h1>计算器</h1></caption> <form action="jsq.php"> <tr> <td> <input type="text" size="5" name="num1" value="<?php echo $_GET["num1"]?>"> </td> <td> <select name="ysf"> <option value="+" <?php echo $_GET["ysf"]=="+"? "selected":""?>>+</option> <option value="-" <?php echo $_GET["ysf"]=="-"? "selected":""?>>-</option> <option value="*" <?php echo $_GET["ysf"]=="*"? "selected":""?>>*</option> <option value="/" <?php echo $_GET["ysf"]=="/"? "selected":""?>>/</option> <option value="%" <?php echo $_GET["ysf"]=="%"? "selected":""?>>%</option> </select> </td> <td> <input type="text" size="5" name="num2" value="<?php echo $_GET["num2"]?>"> </td> <td> <input type="submit" name="sub" value="计算"> </td> </tr> <?php if(isset($_GET["sub"])){ echo '<tr><td colspan="5">'; if($num1 && $num2 && $numa&& $numb){ echo "结果是:".$_GET["num1"]." ".$_GET["ysf"]." ".$_GET["num2"]." = ".$sum; }else{ echo $message; } echo '</td></tr>'; } ?> </form> </table> </body> </html>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The ac key on the calculator is the "all clear" key. The full English name of ac is "All Clear", which means "all clear key"; pressing the ac key means clearing the values in all registers; during number input, the first press Pressing the ac key will clear all values except the memory contents.

The e in the calculator represents the power of 10, which means the exponent with base 10. For example, 1.99714E13 is equal to 19971400000000; expressing a number in the form of a multiplied by the nth power of 10 is called scientific notation. Notation: When we want to mark or operate something larger or smaller with a large number of digits, we can use scientific notation to avoid wasting a lot of space and time.

The win10 system has many powerful functions, which attract many netizens to download, install and use it. There are also many practical gadgets, such as the win10 calculator tool. Some netizens still don’t know how to open the Win10 calculator. Let me teach you how to open the Win10 calculator. Method 1: Search in the Start menu 1. On the Windows 10 system desktop, click the "Start/Calculator" menu item. 2. You can open the calculator window of Windows 10. Method 2: Open Cortana Search 1. On the Windows 10 desktop, click the "Cortana Search" icon in the lower left corner of the taskbar. 2. Enter the keyword "calculator" in the pop-up menu to search, and click the calculator menu item in the search results.

Calculator without storage function refers to scientific calculator; scientific calculator is a type of electronic calculator that can perform operations such as exponentiation, square root, exponent, logarithm, trigonometric function, statistics, etc., also known as Function calculator; a calculator generally consists of a calculator, a controller, a memory, a keyboard, a display, a power supply, and some optional peripherals and electronic accessories.

Efficient Fibonacci sequence calculator: PHP implementation of Fibonacci sequence is a very classic mathematical problem. The rule is that each number is equal to the sum of the previous two numbers, that is, F(n)=F(n -1)+F(n-2), where F(0)=0 and F(1)=1. When calculating the Fibonacci sequence, it can be implemented recursively, but performance problems will occur as the value increases. Therefore, this article will introduce how to write an efficient Fibonacci using PHP

The "AC" key on the calculator means "All Clear". Pressing the AC key will clear all inputs and operations in the calculator and reset the calculator to its initial state, which is equivalent to restarting a calculation.

A simple calculator is a calculator that performs some basic operations, such as "+", "-", "*", "/". The calculator can perform basic operations quickly. We will use the switch statement to make a calculator. Example Operator−‘+’=>34+324=358Operator−‘-’=>3874-324=3550Operator−‘*’=>76*24=1824O

How to implement a simple calculator function using JavaScript? Calculator is one of the commonly used tools in our daily life. It can be used to perform simple mathematical operations. Today, we will use JavaScript to implement a simple calculator function. In this article, I'll show you how to write code in JavaScript to implement basic math operations and calculator interfaces. First, we need to create an HTML file that contains a text for displaying the results of the operation.
