Codeigniter Views Intro


Codeigniter Views : A view in codeigniter is a simple webpage which contains the html which is visible to the user.
Controller is responsible for loading the views or you can load view within a view.


Views are placed under the application/views folder.

Creating Codeigniter Views


Use editor and create the “my_view.php” in the views folder ie. application/views


<html>
<head>
<title>My Home Page</title>
</head>
<body>
<h1>Welcome to the home page.</h1>

<p>More Information Goes Here.......</p>

</body>
</html>

Loading Views

You Can Load Views As Below :

$this->load->view("my_view");

Note : You Need not to add “.php” while loading the view.

Now We Are going to load above view in

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Myblog extends CI_Controller {
  
public function index(){

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

}


}

?>

Demo

Try it »

User Ans/Comments

📖 Read More


Advertisements