Skip to Content
PHPCODE
Codeigniter Create Database
codeigniter code / July 22, 2018

Base Controller step by step created

Step 1 :- go to codeigniter folder and go to core folder
Step 2 :- go to core folder and created file name this(MY_controller.php)
step 3 :-
For Example this like

Note :Why CI_Controller extends beacuase CI_Controller beacuase CI_Controller features used

<?php

class MY_Controller extends CI_Controller
{

}

?>

This used to all controller used not created __construct() write

CI_controller featcures used this class MY_Controller
CI_Controller inheritance  MY_Controller

step 4 :- go to application,Controller Welcome

<?php
class Welcome extends MY_Controller
{

}
?>

Note :MY_Controller inheritance CI_Controller

step 5 :- created admin.php controller and User controller created

Public Controller created this
Articles List
Articles View

Admin Controller created this
Login
Logout
Add Article
Edit Article
Delete Article

<?php
class User extends MY_Controller
{

}
?>
and created public.php controller created
<?php
class public extends MY_Controller
{
public function index()
{
echo  “public index”;
}
}
?>

Note :Controller Created here extends CI_Controller
Why Base Controller Created in Codeigniter ?
ans-> Fox example __construct()created
any load and used any controller that is base controller

What is CI_Controller ?
–>CI_Controller any codeigniter features used extends CI_Controller

PHPCODE © 2024