首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

PHP 5.0对象模型深度探索之属性和方法

整理日期:2007年06月14日 【字体:


伊图教程网[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)
Tags:
PHP 5.0对象模型深度探索之属性和方法
'http://www.etoow.com/html/2007-06/1181788743.html
1
 
2
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved