0
Code igniter : Why we call the parent constructor?
class Test extends CI_Model { function __contruct() { parent::__construct(); } } =>So, my question is, why do we need to call the parent class constructor?... As we are already extending Model class .So, all the properties and methods will be available... so why we need to do so?
1 Resposta
+ 1
Because when you declare a constructor you can also choose to override the Model one. So when you choose not to do so, the program has to know what constructor you will use then. You say that to the program by saying: hey i use the constructor of my parentclass!
That's at least the case for Java, but I guess it applies for PHP as well.