index.php
php code 计算
周长面积计算
正方形 || 三角形 || 圆形
form.class.php
php codeshape=isset($_request[id]) ? $_request[id]:rect; } function __tostring(){ $form='
'; 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='请输入矩形的宽高
'; $input.='宽度:
'; $input.='高度:
'; return $input; } private function gettriangle(){ $input='请输入三角形的三边
'; $input.='第一边:
'; $input.='第二边:
'; $input.='第三边:
'; return $input; } private function getcircle(){ $input='请输入圆的半径
'; $input.='半径:
'; return $input; } }?>
--------------------
点三角形的时候,为什么会输出‘没有这个图形’,那里写错了?
------解决方案--------------------
id=triangle
case triangle:
=====================
understand
