问题
Here's my problem I setup Codeigniter 3 in my local and use an thirdparty (MX thing) now that I have adjusted the file path, I wanted to change the file extension that is being fetch the controller.
$this->load->view('welcome_message');
I change the file in views from:
welcome_message.php
to this
welcome_message.html
Now I get this error
An Error Was Encountered
Unable to load the requested file: welcome_message.php
but I wanted to use the .html extension becuase the folder path that I will be using will only contain html/js/css (template folder) files only (i will separate the php files to template folder). How can this possibly happen?
Any help is greatly appreciated, Thanks guys!
回答1:
You don't need to change extension to html, you can use html in a php file, just don't open php tag.
EDIT :
If you really have to change the ext, just do :
$this->load->view('welcome_message.html');
回答2:
You can try to change it using route configuration in application/config/routes.php
Then, you can use:
$route['[your controller]/welcome_message'] = '[your controller]/welcome_message.html';
For for information about routes, you can check official documentarion here:
http://www.codeigniter.com/user_guide/general/routing.html
Or you can use Static pages:
http://www.codeigniter.com/user_guide/tutorial/static_pages.html
Regards.
来源:https://stackoverflow.com/questions/35205056/how-to-change-the-extension-in-view-using-codeigniter-3