PHP:子から親クラスへアクセスするには?

2021年3月11日木曜日

PHP

t f B! P L

継承した子クラスから親クラスのメソッドを呼び出すには?
※ 子クラスのコンストラクタから親クラスのコンストラクタを呼ぶ出すなど

⇒ "parent"を使う

例:
<?php
  abstruct class Base {
    function __construct(string $id) {
      :
    }
  }

  class Child extends Base {
    function __construct(string $id) {
      parent::__construct($id);
    }
  }


PHP

その他の記事

QooQ