debjit 28 Questions 0 Answers 0 Best Answers 0 Points View Profile 0 debjit Asked: June 7, 2018 How will you call a constructor in CodeIgniter? 0 How will you call a constructor in CodeIgniter? Share Facebook 0 Answers Voted Oldest Recent Random Amir Hussain 5 Questions 28 Answers 0 Best Answers 0 Points View Profile Amir Hussain Added an answer on July 7, 2018 at 11:27 am Anyway, yes, the magic method __construct() is called (automatically) upon each instantiation of the class, Usually, in CI is not necessary to call a constructor, unless you actually want one. You can alternatively put the library/helper/model you want to have alywas loaded in the respective autoload array in config/autoload.php (check “autoloading” in CI’s manual) Once you define a constructor in your child Controller you’re compelled to call the parent constructor (of the mail CI_Controller class), because there is where the main CI object is created and all the classes are loaded, and you need those in your child controller too; if fail to do so your child class will construct separately and won’t inherit. 0 Reply Share Share Share on Facebook Share on Twitter Share on LinkedIn Share on WhatsApp Leave an answerCancel replyYou must login or register to add a new answer.