Home » CodeIgniter Views

CodeIgniter Views

by Online Tutorials Library


What is view

View folder contains all the markup files header, footer, sidebar, etc. They can be reused by embedding anywhere in the controller. They are the interface design which is displayed on the user’s browser and can never be called directly, they have to be loaded in the controller’s file.

View syntax

Create a file and save it in application/views folder. For example, we have created a file Firstview.php,

Codeignter views 1

Loading View

View can’t be accessed directly. It is always loaded in the controller file. The following line is used to load a view page.

Write your view’s page name in the bracket. You don’t need to specify .php unless you are using some other extension.

Now, go to your controller file (Main.php) and write this code as shown below.

Codeigntor views 2

Loading Multiple Views

Your view may contain several files like header, footer, side menu, form, etc. Sometimes you may need to load more than one file simultaneously. In that case, simply call $this->load->view() multiple times.

Codeignter views 3

Next TopicController

You may also like