/*
    * 子类使用父类中的构造方法。
    */

    //父类方法
    class Person {
        //父类中的构造方法
        function __construct(){
            echo '这是父类中的构造方法!';
        }
    }

    //子类方法(继承子父类)
    class MenPerson extends Person {
        //子类重的构造方法
        function __construct(){
            //调用父类中的构造方法
            parent::__construct();
            //调用过之后在继续调用其下的各种实现
            echo '这是子类中的构造方法!';
        }
    }

    //实例化子类对象
    $menp = new MenPerson();

 

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案