Advertisement

Google Ad Slot: content-top

CI Views


What is a View?

A View in CodeIgniter is a PHP file that contains HTML and minimal PHP to display data to the user.

It’s part of the MVC architecture:

  1. Controller sends data
  2. View renders it as HTML
  3. Browser displays it

View File Structure

Views are stored in:

app/
└── Views/
  └── controller-name/
    └── file-name.php

Example: About Page View

About.php
<?php
namespace App\Controllers;

class About extends BaseController
{
public function index()
{
return view('about/index', [
'title' => 'About Us',
'year' => 2025
]);
}
}

View (app/Views/about/index.php)


Example
<h1><?= esc($title) ?></h1>

<p>Copyright © <?= esc($year) ?></p>