Codeigniter include not working?

2019-03-05 23:19发布

问题:

I have a feeling there is a really obvious solution to this but I'm just not seeing it. I'm building a website with codeigniter.

In my views directory I have two folders: template & auth.

I'm trying to include the header from the template directory into a php file in the auth directory.

I'm including it at the top, as always with include '../template/header.php;'

But I'm getting the error:

Message: include(../template/header.php): failed to open stream: No such file or directory

Filename: auth/login.php

回答1:

To include any file in CodeIgniter you should do this :

$this->load->view('template/header');

You can read more about including file in CodeIgniter here :

how to include a file inside a model in codeigniter?