很简单的问题,就是不知道为什么?
index.php
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> <title>计算</title> <body> <p>周长面积计算</p> <p> 正方形 || 三角形 || 圆形 </P> <hr> <?php function __autoload($className){ include $className.'.class.php'; } echo new form; echo $_REQUEST['id']; ?>
form.class.php
- PHP code
<!---ecms 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(){ $f<span style="color:transparent">/本文来源gaodai#ma#com搞*!代#%^码网%</span><sub>搞代gaodaima码</sub>orm=''; switch($this->shape){ case "rect": $form.=$this->getRect(); break; case "Triangle": $form.=$this->getTriangle(); break; case "circle": $form.=$this->getCircle(); break; default: echo '没有这个图形'; } $form.=''; $form.=''; return $form; } private function getRect(){ $input='<p><b>请输入矩形的宽高</b></P>'; $input.='<p>宽度:</p>'; $input.='<p>高度:</p>'; return $input; } private function getTriangle(){ $input='<p><b>请输入三角形的三边</b></P>'; $input.='<p>第一边:</p>'; $input.='<p>第二边:</p>'; $input.='<p>第三边:</p>'; return $input; } private function getCircle(){ $input='<p><b>请输入圆的半径</b></P>'; $input.='<p>半径:</p>'; return $input; } }?>
——————–
点三角形的时候,为什么会输出‘没有这个图形’,那里写错了?
——解决方案——————–
id=triangle
case “Triangle”:
=====================
understand??