🔥 CodeIgniter
Beginner
What is a View in CodeIgniter 4?
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.