Can I use two constructor method in PHP?

336 views Asked by At

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?

1

There are 1 answers

0
Nanocom On BEST ANSWER
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;
    }
}