很简单的问题,就是不知道为什么?
index.php
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><html>
<head>
<title>计算</title>
</head>
<body>
<p><center>周长面积计算</center></p>
<p><center>
<a href="index.php?id=rect">正方形</a> ||
<a href="index.php?id=triangle">三角形</a> ||
<a href="index.php?id=circle">圆形</a>
</center></P>
<hr>
<?php
function __autoload($className){
include $className.'.class.php';
}
echo new form;
echo $_REQUEST['id'];
?>
</body>
</html>
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
class form{
private $shape;
function __construct(){
$this->shape=isset($_REQUEST["id"]) ? $_REQUEST["id"]:"rect";
}
function __toString(){
$form='<form action="" method="post" >';
switch($this->shape){
case "rect":
$form.=$this->getRect();
break;
case "Triangle":
$form.=$this->getTriangle();
break;
case "circle":
$form.=$this->getCircle();
break;
default:
echo '没有这个图形';
}
$form.='<input type="submit" name="sub" value="计算">';
$form.='</form>';
return $form;
}
private function getRect(){
$input='<p><b>请输入矩形的宽高</b></P>';
$input.='<p>宽度:<input type="text" name="width" value="'.$_POST["sub"].'"></p>';
$input.='<p>高度:<input type="text" name="height" value="'.$_POST["sub"].'"></p>';
return $input;
}
private function getTriangle(){
$input='<p><b>请输入三角形的三边</b></P>';
$input.='<p>第一边:<input type="text" name="side1" value="'.$_POST["sub"].'"></p>';
$input.='<p>第二边:<input type="text" name="side2" value="'.$_POST["sub"].'"></p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/xiazai/learn/2559">
<img src="https://img.php.cn/upload/webcode/000/000/000/5a2a54ee20c84366.png" alt="十天学会PHP教程">
</a>
<div class="aritcle_card_info">
<a href="/xiazai/learn/2559">十天学会PHP教程</a>
<p>以前写了十天学会ASP,十天学会ASP.NET什么的,现在想想再写个PHP吧,也算比较全了。 PHP的调试方法我这里就不说了,外面很多文章都有介绍,也有很多不同的组合。我这里暂时是以 Apache web server 和 MY SQL 作为WEB服务器和数据库,在php-4.3.3下的环境做的程序。当然要简单的构建和访问查看数据库 PHPMYADMIN 不可少。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="十天学会PHP教程">
<span>482</span>
</div>
</div>
<a href="/xiazai/learn/2559" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="十天学会PHP教程">
</a>
</div>
';
$input.='<p>第三边:<input type="text" name="side3" value="'.$_POST["sub"].'"></p>';
return $input;
}
private function getCircle(){
$input='<p><b>请输入圆的半径</b></P>';
$input.='<p>半径:<input type="text" name="radius" value="'.$_POST["sub"].'"></p>';
return $input;
}
}
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号