How to use "include / require" in CodeIgniter in the right way?

2

I'm migrating from PHP to CodeIgniter , and would like to know how to use include or require right in my code?

    
asked by anonymous 04.03.2017 / 05:03

2 answers

3

Most things you will use the load class of CodeIgniter. For example:

$this->load->library('usuarios_class');
$this->load->view('usuarios/index-view');
$this->load->model('usuarios_model');

You can take a look at the loader class here: Loader Class - CodeIgniter .

It's important that you understand more or less how the MVC (Model, View, Controller) structure works. Understanding this, you can separate the functions of each one and, using the loader class, call everything you need.

    
08.03.2017 / 14:23
2

Hello. The answer marked correct does not answer when the person really needs to make an include or require.

For those looking for a way to include a PHP (in this case a library), even knowing the MVC structure, it follows:

require_once(APPPATH.'libraries/minhaLibraryAqui.php');
    
16.03.2018 / 18:21