php封装练习
<body> <?php class jisuan { private $a; private $b; function __construct($a,$b) { $this->a = $a; $this->b = $b; } function __set($d,$e) { if($e>0 and $e<100) { $this->$d=$e; } } function __get($d) { return $this->$d; } function he() { return $this->a+$this->b; } function ji() { return $this->a*$this->b; } } $c=new jisuan(10,20); echo $c->he(); echo "<br>"; echo $c->ji(); ?> </body>