0

私は 2 つの php ファイルを持っています: main.class.php form.class.php

これらのファイルには、ファイル名と同じ名前を持つ 2 つのクラスがあり、クラス フォームはメイン クラスから拡張されます メイン クラスにはコンストラクターがあります クラス フォームのコンストラクター メソッドを設定するにはどうすればよいですか?

4

1 に答える 1

2
class Main
{
    private $foo;

    public function __construct($foo)
    {
        $this->foo = $foo;
    }
}

class Form extends Main
{
    private $bar;

    public function __construct($foo, $bar)
    {
        parent::__construct($foo);
        $this->bar = $bar;
    }
}
于 2011-10-31T14:48:52.753 に答える