这是一个类示例。
class Personal [extends Parents] { var $name; var $age; var $sex; function Personal() { $this->name = ""; $this->age = 0; $this->sex = ""; } function Set($n, $a, $s) { $this->name = $n; $this->age = $a; $this->sex = $s; } function Printit() { echo($this->name.$this->age.$this->sex); } } $p = new Personal(); $p->Set('John',20,'man'); $p->Printit(); |
说明 | 意义 |
---|---|
Personal | 类名及构造函数名 |
extends Parents | 从父类继承,可选 |
$this | 引用类实例的指针 |
function | 定义函数及过程 |
new | 生成实例 |