0 votes
in CodeIgniter by
Explain views in CodeIgniter.

1 Answer

0 votes
by

View folder contains all the markup files like header, footer, sidebar, etc. They can be reused by embedding them anywhere in controller file. They can't call directly, and 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,

Creating a View

Using your text editor, create a file called blogview.php, and put this in it:

<html>
<head>
        <title>My Blog</title>
</head>
<body>
        <h1>Welcome to my Blog!</h1>
</body>
</html>

Then save the file in your application/views/ directory.

Loading a View

To load a particular view file you will use the following method:

$this->load->view('name');

Where name is the name of your view file.

Related questions

0 votes
asked Dec 29, 2020 in CodeIgniter by SakshiSharma
0 votes
asked Dec 29, 2020 in CodeIgniter by SakshiSharma
...