Create CodeIgniter Controller

The CodeIgniter Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.

Controller always stored inside Application/controllers folder.Create a Controller

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

class Controller_name extends CI_Controller {

    public function index()
    {

    }
}
?>
            

CI_Controller class must be extended when ever you want to create Your own Controller.

Controller name must be Started with Capital letter.

Controller name and file name must be Same.

By default, it is Welcome.php which is the first page to be seen after installing CodeIgniter.Open website with URL :

 localhost/How to web code/

You can change your default controller in the application/config/routes.php file.

Here, specify your file name which you want to be loaded by default.

$route['default_controller'] = ' ';