Lets say I have an abstract ParentClass and a ChildClass. ChildClass extends ParentClass. Now ParentClass has got this nice constructor:
function __construct($tplFile) {
$this->$tplFile = $tplFile;
}
Will ChildClass automatically inherit this one? And if I don't add any constructor to ChildClass, will I be able to say $foo = new ChildClass("foo.tpl.php");
so that the constructor of ParentClass gets called?
From the PHP manual:
Note: Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required.
ChildClass will automatically inherit the constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With