大圆减去小圆,求阴影面积。大圆半径10,小圆半径5.
一.面向对象方法:
$r1=10;
$r2=5;
$mj=3.14*$r1*$r1-3.14*$r2*r2;
echo $mj;
二.面向过程方法:
class yuan
{
public $r;
function __construct(bj)
{
$this->r=$bj;
}
function mianJi()
{
return 3.14*$this->r*$this->r;
}
}
$y1=new yuan(10);
$y2=new yuan(5);
$zmj=$y1->mianJi()-$y2->mianJI();
eccho $zmj; 别忘了输出