class a{
function a()
{
}
}
在PHP5中,是用新的关键字_construct来实现了,而析构函数则用__destruct()
比如一个例子:
class Person {
function __construct($name)
{
$this->name = $name;
}
function getName()
{
return $this->name;
}
private $name;
};
$judy = new Person("Judy") . "\n";
$joe = new Person("Joe") . "\n";
print $judy->getName();
print $joe->getName();