Frage

I have two php files: main.class.php form.class.php

in these files there are two class that have same name as their file name and class form extends from main class main class has a constructor How can I set a constructor method for class form?

War es hilfreich?

Lösung

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;
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top