circle calculation

Create a new Cirle.class.php file

Verification method:

error .= "半径小于0;"; $bz = false; } else { if (!is_numeric($arr['r'])) { $this->error .= "半径不是数字;"; $bz = false; } } return $bz; }

Except for the verification method and calculation method, the code logic is basically similar. The code is as follows:

r = $arr['r']; } $this->name = "圆形"; $this->error = ''; } function area() { return pi()* $this->r* $this->r; ; } function zhou() { return 2*$this->r*pi(); } function view($arr) { $form=''; $form .= "
"; $form .= "请输入".$arr['name']."的半径:
"; $form .= "
"; $form .= " "; $form .= ""; $form .= "
"; echo $form; } function yan($arr) { $bz = true; if ($arr['r']< 0) { $this->error .= "半径小于0;"; $bz = false; } else { if (!is_numeric($arr['r'])) { $this->error .= "半径不是数字;"; $bz = false; } } return $bz; } } ?>

The running results are as follows:

gif5新文件 (31).gif

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!