<?php
class BaseClass{
function __construct(){
echo "<br><font color=red>this is the base class constructor</font><br>";
}
}
class SubClass extends BaseClass{
function __construct(){
#子类调用父类构造方法的两种,父类名::__construct();parent::__construct()
BaseClass::__construct();
parent::__construct();
echo" <br> this is the sub class constructor<br>";
}
}
echo "declare an instance of BaseClass<br>";
$obj=new BaseClass();
echo "declare an instance of SubClass<br>";
$obj1=new SubClass();
?>
posted on 2009-06-28 13:34
期待明天 阅读(401)
评论(0) 编辑 收藏 所属分类:
PHP