亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    php調(diào)用父類構(gòu)造方法是什么

    php調(diào)用父類構(gòu)造方法:首先父類先構(gòu)造函數(shù),代碼為【public function __construct()】;然后使用【parent::__construct()】調(diào)用父類構(gòu)造函數(shù)即可。

    php調(diào)用父類構(gòu)造方法是什么

    php調(diào)用父類構(gòu)造方法:

    一、使用函數(shù)【parent::__construct()】調(diào)用父類構(gòu)造函數(shù)

    代碼如下;

    <?php class MyClass    //父類 {     public function __construct()    //父類構(gòu)造函數(shù) {     echo "父類的構(gòu)造函數(shù)"; } } class ChildClass extends MyClass     //子類  {     public function __construct()    //子類構(gòu)造函數(shù) {         echo "子類的構(gòu)造函數(shù)"."<br>";         parent::__construct();    //調(diào)用父類構(gòu)造函數(shù)     } } $childClass = new ChildClass();    //對(duì)類的實(shí)例化 ?>

    二、運(yùn)行結(jié)果

    子類的構(gòu)造函數(shù)

    父類的構(gòu)造函數(shù)

    相關(guān)學(xué)習(xí)推薦:php編程(視頻)

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)