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>

Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.