php面向对象构造一个圆类
<?php
class Yuan
{
var $banjing;//圆类的一个成员变量
//面积成员方法
function mianji()
{
return 3.14*$this->banjing*$this->banjing;
}
}
//2.实例化对象
//$yuan = new Yuan();
//$yuan->banjing = 10;
//echo $yuan->MianJi();
//var_dump($yuan);
//$this关键字在类里面代表该对象
//造一个大圆
$maxyuan = new Yuan();
$maxyuan->banjing = 10;
//造一个小圆
$minyuan = new Yuan();
$minyuan->banjing = 5;
echo $maxyuan->MianJi()-$minyuan->MianJi();
?>