php extends

header ("content-type:text/html;charset=utf-8");

class A{

  function __construct(){

    echo "基类的构造方法<br/>";

  }

}

class B extends A{

  function __construct(){

    parent::__construct();

    echo "子类B的构造方法<br/>";

    self::myfun();

  }

  function myfun(){

    echo "一个普通的方法:myfun()<br/>";

  }

}

$obj = new A();

$obj = new B();

 

posted @ 2017-03-15 17:25  yahn~  阅读(240)  评论(0)    收藏  举报