<html>
<body>
class Fruit {
// 属性
public $name;
public $color;
// 方法
function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}
}
$apple = new Fruit();
$banana = new Fruit();
$apple->set_name('苹果');
$banana->set_name('香蕉');
echo $apple->get_name();
echo "<br>";
echo $banana->get_name();
</body>
</html>