伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-06/1181788743.html
public $room;
}
//create empty house
$home = new house;
//add some rooms
$home->room[] = new Room("bedroom");
$home->room[] = new Room("kitchen");
$home->room[] = new Room("bathroom");
//show the first room of the house
print($home->room[0]->name);
?>
PHP有两个特殊的命名空间:parent命名空间指向父类,self命名空间指向当前的类。下面的例子中显示了如何用parent命名空间来调用父类中的构造函数. 同时也用self来在构造函数中调用另一个类方法。
class Animal //动物
{
public $blood; //热血or冷血属性
public $name;
public function __construct($blood, $name=NULL)
PHP 5.0对象模型深度探索之属性和方法
'http://www.etoow.com/html/2007-06/1181788743.html