-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
57 lines (52 loc) · 1.16 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
if ($_GET["num1"])
{
$x=$_GET["num1"];
$y=$_GET["num2"];
$operator=$_GET["operator"];
if($operator=="+")
{
$res=$x+$y;
}
elseif($operator=="-")
{
$res=$x-$y;
}
elseif($operator=="*")
{
$res=$x*$y;
}
elseif($operator=="/")
{
$res=$x/$y;
}
}
if(empty($x) && empty($y))
{
$res = "Не все данные введены";
}
if(!empty($_REQUEST["res"]))
{
$enter = "Результат: $res";
}
?>
<html>
<head>
</head>
<body>
<form >
<input type="text" name="num1" placeholder="первое число">
<select name="operator">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" name="num2" placeholder="второе число">
<input type="submit" name="res" value="Результат" />
</form>
<?php echo $enter?>
</body>
</html>
<?php
?>