1.求圆的面积
先用VSC建立.php文件和.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>yuan</title>
</head>
<body>
<?php
define('pi',3.14);
function yuan(){//圆的面积
$r=$_GET['r'];
echo pi*$r*$r;
}
yuan();
echo "<br>";
?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>yuan</title>
</head>
<body>
<form action="h2.php" method="GET">//action=""输入.php文件名
输入圆半径: <input type="text" name="r">
<input type="submit">
</form>
</body>
</html>
运行效果:
2.求三角形的面积
先用VSC建立.php文件和.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sanjiaoxing</title>
</head>
<body>
<?php
function sanjiao()//三角形的面积
{
$s = $_GET['s'];
$h = $_GET['h'];
echo $s * $h * 1 / 2;
}
sanjiao();
echo "<br>";
?>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sanjiaoxing</title>
</head>
<body>
<form action="h3.php" method="GET">
输入s:<input type="text" name="s">
输入h:<input type="text" name="h">
<input type="submit">
</form>
</body>
</html>
运行效果: