What is a View in CodeIgniter 4?

Why Interviewers Ask This

This is a classic screening question for CodeIgniter roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

Views in CodeIgniter are simple PHP files stored in app/Views/ that contain HTML mixed with PHP. Load a view from a controller: return view("blog/index", ["title" => "My Blog", "posts" => $posts]). The second argument passes data as an array — these become variables in the view ($title, $posts). Views can include other views: <?= view("partials/header") ?>. Unlike Laravel's Blade, CI4 does not have a dedicated templating language by default — views are plain PHP. However, CI4 does include a simple View Parser for pseudo-variables ({title}), conditionals, and loops without PHP tags. For richer templating, third-party libraries or Twig can be integrated.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a CodeIgniter codebase.