很简单的问题,就是不知道为什么?
index.php
- PHP code
<!--
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>
form.class.php
- PHP code
<!--
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 flexRow">
<div class="artcardd flexRow">
<a class="aritcle_card_img" href="/ai/857" title="ChatDOC"><img
src="https://img.php.cn/upload/ai_manual/001/503/042/68b6d657cd5a6840.png" alt="ChatDOC" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a href="/ai/857" title="ChatDOC">ChatDOC</a>
<p>ChatDOC是一款基于chatgpt的文件阅读助手,可以快速从pdf中提取、定位和总结信息</p>
</div>
<a href="/ai/857" title="ChatDOC" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span> </a>
</div>
</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;
}
}
?>
--------------------
点三角形的时候,为什么会输出‘没有这个图形’,那里写错了?
------解决方案--------------------
id=triangle
case "Triangle":
=====================
understand??









