Page 1 of 1

parent::__construct() - does the order matter?

Posted: Thu Aug 31, 2006 4:11 pm
by Luke
Does it matter whether you call the parent constructer like this:

Code: Select all

function __construct(){
// Do stuff
parent::__construct();
}
as opposed to this:

Code: Select all

function __construct(){
parent::__construct();
// Do stuff
}

Posted: Thu Aug 31, 2006 4:17 pm
by feyd
It only matters in how your class needs things. i.e. if you class needs information that would be filled in by the parent's constructor, then you need to construct it first. If it doesn't matter to the child then it doesn't really matter when you call it. I personally try to call the parent's constructor first always.