<?php
class Person{
private $name;
private $weight;
private $height;
public function __construct($name, $weight, $height){
$this->name=$name;
$this->weight=$weight;
$this->height=$height;
}
public function getName() {
echo $this->name;
}
public function getWeight() {
echo "体重是".$this->weight."kg。";
}
public function getHeight() {
echo "身高是".$this->height."cm,";
}
}
$person = new Person('明明', '51.5', '165');
echo $person->getName();
echo '的';
echo $person->getHeight();
echo $person->getWeight();
?>