<body> <?php class jisuan { private $a; private $b; function __set($d,$e) { if($d=="a") { if($e>0 and $e<100) { $this->$d=$e; } } else if($d="b") { if($e>0 and $e<100) { $this->$d=$e; } } } function __get($d) { return $this->$d; } } $c=new jisuan(); $c->a=10; $c->b=20; echo $he=$c->a+$c->b; echo "<br>"; echo $ji=$c->a*$c->b; ?> </body>
时间: 2024-10-22 23:46:58