Hướng dẫn how to design a simple calculator in php? - làm thế nào để thiết kế một máy tính đơn giản trong php?

Chương trình PHP để tạo một máy tính đơn giản:

Chương trình dưới đây là tạo một máy tính đơn giản trong php.example
Example

DOCTYPE html>
<html>
<body>
 
php
ini_set('display_errors',0);
 
if( isset( $_REQUEST['calculate'] ))
{
$operator=$_REQUEST['operator'];
$n1 = $_REQUEST['first_value'];
$n2 = $_REQUEST['second_value'];
 
if($operator=="+")
{
$res= $n1+$n2;
}
if($operator=="-")
{
$res= $n1-$n2;
}
if($operator=="*")
{
$res =$n1*$n2;
}
if($operator=="/")
{
$res= $n1/$n2;
}
 
if($_REQUEST['first_value']==NULL || $_REQUEST['second_value']==NULL)
{
echo "";
}
}
?>
 
<form>
<table style="border:groove #00FF99">
 
<tr>
<td style="background-color:turquoise; color:black; font-family:'Times New Roman'">Enter Numbertd>
<td colspan="1">
<input name="first_value" type="text" style="color:red"/>td>
tr>
 
<tr>
<td style="color:red; font-family:'Times New Roman'">Select Operatortd>
<td>
<select name="operator" style="width: 63px">
<option>+option>
<option>-option>
<option>*option>
<option>/option>
select>td>
tr>
 
<tr>
<td style="background-color:turquoise; color:black; font-family:'Times New Roman'">Enter Numbertd>
<td class="auto-style5">
<input name="second_value" type="text"  style="color:red"/>td> 
tr>
 
<tr>
<td>td>
<td><input type="submit" name="calculate" value="Calculate" style="color:wheat;background-color:rosybrown" />td>	 
tr>
 
<tr>
<td style="background-color:turquoise;color:black">Output = td>
<td style="color:darkblue">php echo $res;?>td>
tr>	
 
table>
form>
 
body>
html>

Hướng dẫn how to design a simple calculator in php? - làm thế nào để thiết kế một máy tính đơn giản trong php?

Làm thế nào để tạo máy tính trong trường PHP W3Schools?

Mã PHP: php if ($_SERVER["REQUEST_METHOD"] == "POST") { $Operand1=$_POST['Operand1']; $Operand2=$_POST['Operand2']; $Operator=$_POST['Calculate']; /*Validation begins from here.

Làm thế nào tôi có thể tính toán trong PHP?

PHP có một tập hợp các chức năng toán học cho phép bạn thực hiện các tác vụ toán học trên các số ...
Hàm php pi ().Hàm pi () trả về giá trị của pi: ....
Các hàm php min () và tối đa ().....
Hàm PHP ABS ().....
Hàm php sqrt ().....
Chức năng vòng php () ..

HTML có thể tạo máy tính không?

HTML được sử dụng để thiết kế cấu trúc cơ bản của máy tính.Các kiểu CSS được sử dụng để áp dụng các kiểu trên máy tính và JavaScript được sử dụng để thêm chức năng tính toán.. CSS styles are used to apply styles on the calculator and JavaScript is used to add the calculation functionality.