代码内容:
<?php
class Person{
var $name;
var $sex;
var $age;
var $height;
var $weight;
var $birthe;
//该对象的姓名"王二麻子", 性别"男", 年龄"17", 身高"176.5", 体重"73.5", 出生年月"1997/9/23",最后调用该对象的自我描述方法
function __construct($name,$sex,$age,$height,$weight,$birthe){
$this->name = $name;
$this->sex = $sex;
$this->age = $age;
$this->height = $height;
$this->weight = $weight;
$this->birthe = $birthe;
}
function p(){
echo "姓名:".$this->name.",性别:".$this->sex.",年龄:".$this->age.",身高:".$this->height.",体重:".$this->weight.",出生日期:".$this->birthe;
}
}
$s1 = new Person('王二麻子','男',17,"176.5","73.5","1997/9/23");
$s1->p();
?>
效果演示: