CodeIgniter Controller Constructor

前端 未结 4 1735
一整个雨季
一整个雨季 2021-02-07 10:34

I\'m very new to codeigniter , I wanted to know what is the meaning of a constructor in a controller . I saw the following code in a codeigniter tutorial -

cla         


        
4条回答
  •  感情败类
    2021-02-07 10:58

    That's a general question. Constructor is a function that is automatically called when instantiated. this function helps us to intialize the things that we are going to need frequently in our code like when we have to load the models of helpers like form e.t.c.

    $this->load->model('Model_name');
    

    now when you write this line in your constructor you don't need to load this model again and again in your methods of that class.

提交回复
热议问题