What are views in CodeIgniter

Views are very important in CodeIgniter. These are HTML files which used to create user interfaces. Sometimes we have embedded PHP in it to create dynamic web pages. We can pass variables and objects to CodeIgniter view to load dynamic content. Through controllers we render views. We can execute condition and loop statements also in CodeIgniter views. We need to create views in application/views folder. Examples of views are mentioned below html view


//student_details.php
<html>
<head>
  <title>Student Details</title>
</head>
<body>
  <h1>Hello, <?php echo $student_detail->name ?></h1>

<table>
    <tr><td>Roll No.</td><td><?php echo $student_detail->roll_no?></td></tr>
    <tr><td>Class</td><td><?php echo $student_detail->class?></td></tr>      
</table>
</body>
</html>
To load views in controller we can use below mentioned code:

class Students extends CI_Controller {

    public function index() {
        $this->load->model('Student_model');
        $data['student_detail'] = $this->Student_model->get_student_details($id);
        $this->load->view('student_details', $data);
    }
}