// 定义一个类 class Student{ public $name; public $sex; public $age; } // 创建对象 $stu = new Student(); $stu->name = "张三"; $stu->sex = "男"; $stu->age = 22; // 输出 echo "姓名:".($stu->name).",性别:".($stu->sex).",年龄:".($stu->age);
输出:
姓名:张三,性别:男,年龄:22
// 定义一个类 class Student{ public $name; public $sex; public $age; } // 创建对象 $stu = new Student(); $stu->name = "张三"; $stu->sex = "男"; $stu->age = 22; // 输出 echo "姓名:".($stu->name).",性别:".($stu->sex).",年龄:".($stu->age);
输出:
姓名:张三,性别:男,年龄:22