<?php
class Person {
public function __construct($name, $gender, $age) {
$this -> name = $name;
$this -> gender = $gender;
$this -> age = $age;
$this -> say();
}
public function say() {
echo "我的名字是:" .$this -> name. " 我的性别是:" .$this -> gender. " 我的年龄是:" .$this -> age. "<br>";
}
}
$p1 = new Person("张三", "男", 20);
$p2 = new Person("李四", "女", 19);
$p3 = new Person("王五", "男", 18);
?>