What is the function of __construct() in CodeIgniter?












1















I work with CodeIgniter framework and I'm new to this. In the following code, __construct() function is used for loading a model.




  • Why do I need to use __construct()?

  • When should I use this function?

  • What is parent::__construct()?


Code



function __construct() {
parent::__construct();
$this->load->model('example');
}









share|improve this question

























  • I think parent construct is getting axed in the next version for models.

    – Alex
    Feb 24 '18 at 19:18
















1















I work with CodeIgniter framework and I'm new to this. In the following code, __construct() function is used for loading a model.




  • Why do I need to use __construct()?

  • When should I use this function?

  • What is parent::__construct()?


Code



function __construct() {
parent::__construct();
$this->load->model('example');
}









share|improve this question

























  • I think parent construct is getting axed in the next version for models.

    – Alex
    Feb 24 '18 at 19:18














1












1








1


1






I work with CodeIgniter framework and I'm new to this. In the following code, __construct() function is used for loading a model.




  • Why do I need to use __construct()?

  • When should I use this function?

  • What is parent::__construct()?


Code



function __construct() {
parent::__construct();
$this->load->model('example');
}









share|improve this question
















I work with CodeIgniter framework and I'm new to this. In the following code, __construct() function is used for loading a model.




  • Why do I need to use __construct()?

  • When should I use this function?

  • What is parent::__construct()?


Code



function __construct() {
parent::__construct();
$this->load->model('example');
}






php codeigniter construct






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 24 '18 at 15:43









Andrew T.

4,34452849




4,34452849










asked Jun 3 '16 at 20:04









mohsenmohsen

17113




17113













  • I think parent construct is getting axed in the next version for models.

    – Alex
    Feb 24 '18 at 19:18



















  • I think parent construct is getting axed in the next version for models.

    – Alex
    Feb 24 '18 at 19:18

















I think parent construct is getting axed in the next version for models.

– Alex
Feb 24 '18 at 19:18





I think parent construct is getting axed in the next version for models.

– Alex
Feb 24 '18 at 19:18












3 Answers
3






active

oldest

votes


















1














The construct function lets you use things over the entire class.
This way you don't have to load the model/language/settings in every method.



Say you have a model and language that you want to load for that class, you can do this in the constructor. If you have for example an email method in the class and only use email in that class, you dont have to set this in the constructor but in the method. This way it doesn't get loaded unneeded for all the other methods that dont use it.



    class Contact extends CI_Controller {

public function __construct(){
parent::__construct();
$this->load->model('contact_model', 'contact');
}

public function index(){
$data['contact'] = $this->contact->getContact();
$this->load->view('contact', $data);
}

public function send_mail(){
/* Mail configuration - ONLY USED HERE */
$config = array('protocol' => 'mail',
'wordwrap' => FALSE,
'mailtype' => 'html',
'charset' => 'utf-8',
'crlf' => "rn",
'newline' => "rn",
'send_multipart' => FALSE
);
$this->load->library('email', $config);
$records = $this->contact->getCompany();

$this->email->from( $setmail, $records['CompanyName'] );
$this->email->to( $to );
$this->email->subject( $subject );
$this->email->message( $html );
$this->email->send();
}

}


From php: http://php.net/manual/en/language.oop5.decon.php




PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.







share|improve this answer


























  • What is the name of this symbol : " -> " , and what is the purpose?

    – Gem
    Jun 19 '18 at 6:15



















-1














<?php 
class Stud_controller extends CI_Controller {

function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->database();
}

public function index() {
$query = $this->db->get("stud");
$data['records'] = $query->result();

$this->load->helper('url');
$this->load->view('Stud_view',$data);
}

public function add_student_view() {
$this->load->helper('form');
$this->load->view('Stud_add');
}

public function add_student() {
$this->load->model('Stud_Model');

$data = array(
'roll_no' => $this->input->post('roll_no'),
'name' => $this->input->post('name')
);

$this->Stud_Model->insert($data);

$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->view('Stud_view',$data);
}

public function update_student_view() {
$this->load->helper('form');
$roll_no = $this->uri->segment('3');
$query = $this->db->get_where("stud",array("roll_no"=>$roll_no));
$data['records'] = $query->result();
$data['old_roll_no'] = $roll_no;
$this->load->view('Stud_edit',$data);
}

public function update_student(){
$this->load->model('Stud_Model');

$data = array(
'roll_no' => $this->input->post('roll_no'),
'name' => $this->input->post('name')
);

$old_roll_no = $this->input->post('old_roll_no');
$this->Stud_Model->update($data,$old_roll_no);

$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->view('Stud_view',$data);
}

public function delete_student() {
$this->load->model('Stud_Model');
$roll_no = $this->uri->segment('3');
$this->Stud_Model->delete($roll_no);

$query = $this->db->get("stud");
$data['records'] = $query->result();
$this->load->view('Stud_view',$data);
}
}
?>





share|improve this answer





















  • 4





    Can you add some explanation to your code? Why do you think that it solves the problem?

    – Nico Haase
    Nov 27 '18 at 14:18



















-1














 function __construct(){
parent::__construct();
//predefined view,models,etc..,
}


__construct function let's you define model,view,helper and other libraries, on the top of a class.
it's these model,views are belongs to that class
so, you no need to be load these for each function you call or create
once it's create it's take care of the rest of your class.



public function __construct(){
parent::__construct();
$this->load->model('your_model_name');
$this->load->view('your_view_name');
}





share|improve this answer








New contributor




teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37622520%2fwhat-is-the-function-of-construct-in-codeigniter%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The construct function lets you use things over the entire class.
    This way you don't have to load the model/language/settings in every method.



    Say you have a model and language that you want to load for that class, you can do this in the constructor. If you have for example an email method in the class and only use email in that class, you dont have to set this in the constructor but in the method. This way it doesn't get loaded unneeded for all the other methods that dont use it.



        class Contact extends CI_Controller {

    public function __construct(){
    parent::__construct();
    $this->load->model('contact_model', 'contact');
    }

    public function index(){
    $data['contact'] = $this->contact->getContact();
    $this->load->view('contact', $data);
    }

    public function send_mail(){
    /* Mail configuration - ONLY USED HERE */
    $config = array('protocol' => 'mail',
    'wordwrap' => FALSE,
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'crlf' => "rn",
    'newline' => "rn",
    'send_multipart' => FALSE
    );
    $this->load->library('email', $config);
    $records = $this->contact->getCompany();

    $this->email->from( $setmail, $records['CompanyName'] );
    $this->email->to( $to );
    $this->email->subject( $subject );
    $this->email->message( $html );
    $this->email->send();
    }

    }


    From php: http://php.net/manual/en/language.oop5.decon.php




    PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.







    share|improve this answer


























    • What is the name of this symbol : " -> " , and what is the purpose?

      – Gem
      Jun 19 '18 at 6:15
















    1














    The construct function lets you use things over the entire class.
    This way you don't have to load the model/language/settings in every method.



    Say you have a model and language that you want to load for that class, you can do this in the constructor. If you have for example an email method in the class and only use email in that class, you dont have to set this in the constructor but in the method. This way it doesn't get loaded unneeded for all the other methods that dont use it.



        class Contact extends CI_Controller {

    public function __construct(){
    parent::__construct();
    $this->load->model('contact_model', 'contact');
    }

    public function index(){
    $data['contact'] = $this->contact->getContact();
    $this->load->view('contact', $data);
    }

    public function send_mail(){
    /* Mail configuration - ONLY USED HERE */
    $config = array('protocol' => 'mail',
    'wordwrap' => FALSE,
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'crlf' => "rn",
    'newline' => "rn",
    'send_multipart' => FALSE
    );
    $this->load->library('email', $config);
    $records = $this->contact->getCompany();

    $this->email->from( $setmail, $records['CompanyName'] );
    $this->email->to( $to );
    $this->email->subject( $subject );
    $this->email->message( $html );
    $this->email->send();
    }

    }


    From php: http://php.net/manual/en/language.oop5.decon.php




    PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.







    share|improve this answer


























    • What is the name of this symbol : " -> " , and what is the purpose?

      – Gem
      Jun 19 '18 at 6:15














    1












    1








    1







    The construct function lets you use things over the entire class.
    This way you don't have to load the model/language/settings in every method.



    Say you have a model and language that you want to load for that class, you can do this in the constructor. If you have for example an email method in the class and only use email in that class, you dont have to set this in the constructor but in the method. This way it doesn't get loaded unneeded for all the other methods that dont use it.



        class Contact extends CI_Controller {

    public function __construct(){
    parent::__construct();
    $this->load->model('contact_model', 'contact');
    }

    public function index(){
    $data['contact'] = $this->contact->getContact();
    $this->load->view('contact', $data);
    }

    public function send_mail(){
    /* Mail configuration - ONLY USED HERE */
    $config = array('protocol' => 'mail',
    'wordwrap' => FALSE,
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'crlf' => "rn",
    'newline' => "rn",
    'send_multipart' => FALSE
    );
    $this->load->library('email', $config);
    $records = $this->contact->getCompany();

    $this->email->from( $setmail, $records['CompanyName'] );
    $this->email->to( $to );
    $this->email->subject( $subject );
    $this->email->message( $html );
    $this->email->send();
    }

    }


    From php: http://php.net/manual/en/language.oop5.decon.php




    PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.







    share|improve this answer















    The construct function lets you use things over the entire class.
    This way you don't have to load the model/language/settings in every method.



    Say you have a model and language that you want to load for that class, you can do this in the constructor. If you have for example an email method in the class and only use email in that class, you dont have to set this in the constructor but in the method. This way it doesn't get loaded unneeded for all the other methods that dont use it.



        class Contact extends CI_Controller {

    public function __construct(){
    parent::__construct();
    $this->load->model('contact_model', 'contact');
    }

    public function index(){
    $data['contact'] = $this->contact->getContact();
    $this->load->view('contact', $data);
    }

    public function send_mail(){
    /* Mail configuration - ONLY USED HERE */
    $config = array('protocol' => 'mail',
    'wordwrap' => FALSE,
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'crlf' => "rn",
    'newline' => "rn",
    'send_multipart' => FALSE
    );
    $this->load->library('email', $config);
    $records = $this->contact->getCompany();

    $this->email->from( $setmail, $records['CompanyName'] );
    $this->email->to( $to );
    $this->email->subject( $subject );
    $this->email->message( $html );
    $this->email->send();
    }

    }


    From php: http://php.net/manual/en/language.oop5.decon.php




    PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 4 '16 at 12:35

























    answered Jun 4 '16 at 12:10









    Davy BaccaertDavy Baccaert

    114




    114













    • What is the name of this symbol : " -> " , and what is the purpose?

      – Gem
      Jun 19 '18 at 6:15



















    • What is the name of this symbol : " -> " , and what is the purpose?

      – Gem
      Jun 19 '18 at 6:15

















    What is the name of this symbol : " -> " , and what is the purpose?

    – Gem
    Jun 19 '18 at 6:15





    What is the name of this symbol : " -> " , and what is the purpose?

    – Gem
    Jun 19 '18 at 6:15













    -1














    <?php 
    class Stud_controller extends CI_Controller {

    function __construct() {
    parent::__construct();
    $this->load->helper('url');
    $this->load->database();
    }

    public function index() {
    $query = $this->db->get("stud");
    $data['records'] = $query->result();

    $this->load->helper('url');
    $this->load->view('Stud_view',$data);
    }

    public function add_student_view() {
    $this->load->helper('form');
    $this->load->view('Stud_add');
    }

    public function add_student() {
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $this->Stud_Model->insert($data);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function update_student_view() {
    $this->load->helper('form');
    $roll_no = $this->uri->segment('3');
    $query = $this->db->get_where("stud",array("roll_no"=>$roll_no));
    $data['records'] = $query->result();
    $data['old_roll_no'] = $roll_no;
    $this->load->view('Stud_edit',$data);
    }

    public function update_student(){
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $old_roll_no = $this->input->post('old_roll_no');
    $this->Stud_Model->update($data,$old_roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function delete_student() {
    $this->load->model('Stud_Model');
    $roll_no = $this->uri->segment('3');
    $this->Stud_Model->delete($roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }
    }
    ?>





    share|improve this answer





















    • 4





      Can you add some explanation to your code? Why do you think that it solves the problem?

      – Nico Haase
      Nov 27 '18 at 14:18
















    -1














    <?php 
    class Stud_controller extends CI_Controller {

    function __construct() {
    parent::__construct();
    $this->load->helper('url');
    $this->load->database();
    }

    public function index() {
    $query = $this->db->get("stud");
    $data['records'] = $query->result();

    $this->load->helper('url');
    $this->load->view('Stud_view',$data);
    }

    public function add_student_view() {
    $this->load->helper('form');
    $this->load->view('Stud_add');
    }

    public function add_student() {
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $this->Stud_Model->insert($data);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function update_student_view() {
    $this->load->helper('form');
    $roll_no = $this->uri->segment('3');
    $query = $this->db->get_where("stud",array("roll_no"=>$roll_no));
    $data['records'] = $query->result();
    $data['old_roll_no'] = $roll_no;
    $this->load->view('Stud_edit',$data);
    }

    public function update_student(){
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $old_roll_no = $this->input->post('old_roll_no');
    $this->Stud_Model->update($data,$old_roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function delete_student() {
    $this->load->model('Stud_Model');
    $roll_no = $this->uri->segment('3');
    $this->Stud_Model->delete($roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }
    }
    ?>





    share|improve this answer





















    • 4





      Can you add some explanation to your code? Why do you think that it solves the problem?

      – Nico Haase
      Nov 27 '18 at 14:18














    -1












    -1








    -1







    <?php 
    class Stud_controller extends CI_Controller {

    function __construct() {
    parent::__construct();
    $this->load->helper('url');
    $this->load->database();
    }

    public function index() {
    $query = $this->db->get("stud");
    $data['records'] = $query->result();

    $this->load->helper('url');
    $this->load->view('Stud_view',$data);
    }

    public function add_student_view() {
    $this->load->helper('form');
    $this->load->view('Stud_add');
    }

    public function add_student() {
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $this->Stud_Model->insert($data);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function update_student_view() {
    $this->load->helper('form');
    $roll_no = $this->uri->segment('3');
    $query = $this->db->get_where("stud",array("roll_no"=>$roll_no));
    $data['records'] = $query->result();
    $data['old_roll_no'] = $roll_no;
    $this->load->view('Stud_edit',$data);
    }

    public function update_student(){
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $old_roll_no = $this->input->post('old_roll_no');
    $this->Stud_Model->update($data,$old_roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function delete_student() {
    $this->load->model('Stud_Model');
    $roll_no = $this->uri->segment('3');
    $this->Stud_Model->delete($roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }
    }
    ?>





    share|improve this answer















    <?php 
    class Stud_controller extends CI_Controller {

    function __construct() {
    parent::__construct();
    $this->load->helper('url');
    $this->load->database();
    }

    public function index() {
    $query = $this->db->get("stud");
    $data['records'] = $query->result();

    $this->load->helper('url');
    $this->load->view('Stud_view',$data);
    }

    public function add_student_view() {
    $this->load->helper('form');
    $this->load->view('Stud_add');
    }

    public function add_student() {
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $this->Stud_Model->insert($data);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function update_student_view() {
    $this->load->helper('form');
    $roll_no = $this->uri->segment('3');
    $query = $this->db->get_where("stud",array("roll_no"=>$roll_no));
    $data['records'] = $query->result();
    $data['old_roll_no'] = $roll_no;
    $this->load->view('Stud_edit',$data);
    }

    public function update_student(){
    $this->load->model('Stud_Model');

    $data = array(
    'roll_no' => $this->input->post('roll_no'),
    'name' => $this->input->post('name')
    );

    $old_roll_no = $this->input->post('old_roll_no');
    $this->Stud_Model->update($data,$old_roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }

    public function delete_student() {
    $this->load->model('Stud_Model');
    $roll_no = $this->uri->segment('3');
    $this->Stud_Model->delete($roll_no);

    $query = $this->db->get("stud");
    $data['records'] = $query->result();
    $this->load->view('Stud_view',$data);
    }
    }
    ?>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 27 '18 at 13:22









    AS Mackay

    2,0034820




    2,0034820










    answered Nov 27 '18 at 13:08









    user10711735user10711735

    1




    1








    • 4





      Can you add some explanation to your code? Why do you think that it solves the problem?

      – Nico Haase
      Nov 27 '18 at 14:18














    • 4





      Can you add some explanation to your code? Why do you think that it solves the problem?

      – Nico Haase
      Nov 27 '18 at 14:18








    4




    4





    Can you add some explanation to your code? Why do you think that it solves the problem?

    – Nico Haase
    Nov 27 '18 at 14:18





    Can you add some explanation to your code? Why do you think that it solves the problem?

    – Nico Haase
    Nov 27 '18 at 14:18











    -1














     function __construct(){
    parent::__construct();
    //predefined view,models,etc..,
    }


    __construct function let's you define model,view,helper and other libraries, on the top of a class.
    it's these model,views are belongs to that class
    so, you no need to be load these for each function you call or create
    once it's create it's take care of the rest of your class.



    public function __construct(){
    parent::__construct();
    $this->load->model('your_model_name');
    $this->load->view('your_view_name');
    }





    share|improve this answer








    New contributor




    teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      -1














       function __construct(){
      parent::__construct();
      //predefined view,models,etc..,
      }


      __construct function let's you define model,view,helper and other libraries, on the top of a class.
      it's these model,views are belongs to that class
      so, you no need to be load these for each function you call or create
      once it's create it's take care of the rest of your class.



      public function __construct(){
      parent::__construct();
      $this->load->model('your_model_name');
      $this->load->view('your_view_name');
      }





      share|improve this answer








      New contributor




      teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        -1












        -1








        -1







         function __construct(){
        parent::__construct();
        //predefined view,models,etc..,
        }


        __construct function let's you define model,view,helper and other libraries, on the top of a class.
        it's these model,views are belongs to that class
        so, you no need to be load these for each function you call or create
        once it's create it's take care of the rest of your class.



        public function __construct(){
        parent::__construct();
        $this->load->model('your_model_name');
        $this->load->view('your_view_name');
        }





        share|improve this answer








        New contributor




        teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










         function __construct(){
        parent::__construct();
        //predefined view,models,etc..,
        }


        __construct function let's you define model,view,helper and other libraries, on the top of a class.
        it's these model,views are belongs to that class
        so, you no need to be load these for each function you call or create
        once it's create it's take care of the rest of your class.



        public function __construct(){
        parent::__construct();
        $this->load->model('your_model_name');
        $this->load->view('your_view_name');
        }






        share|improve this answer








        New contributor




        teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Feb 25 at 7:14









        teenage vampireteenage vampire

        11




        11




        New contributor




        teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        teenage vampire is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37622520%2fwhat-is-the-function-of-construct-in-codeigniter%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)