How Codeigniter Works | Method in CI | View in CI | Controller in C

O7services > O7 blogs  > How Codeigniter Works | Method in CI | View in CI | Controller in C
How Codeigniter Works

How Codeigniter Works | Method in CI | View in CI | Controller in C

How Codeigniter works

How Codeigniter works is the one of the query which arises in the mind of every individual who is new to CI. Following are the steps which will help you to clarify such sort of questions.

  1. Start WAMP/XAMPP/LAMP server.
  2. Run your Codeigniter page/folder.
  3. Click on application -> controller -> welcome.php
    • Here we can load function, views from the controller.
  4.  Set Base path
  • SYNTAX: defined(“BASEPATH”). OR exit(“no direct script access allowed”);

This line is used as session for the security. It will restrict the user from directly accessing the page.

How to create new method in page?

To create a new method , create a new function.


public function myindex()

echo “my Index”;


To run this method, write the following in the address bar:




Existing or New View in CI

Existing view:



Here  is the view  named welcome_message

  • welcome_message is the view of welcome on index.php function.
  • If you want to make changes in welcome_message or any other existing view then make changes in the code of that particular view.




If there is no index function and user also doesn’t mention any function/controller then it will gives us an error of 404 i.e page not found.




Syntax to load another view in the new function


where ‘myindex_view‘ is the name of new view

How to control new controller?

  • click on controller -> create -> save as with name ‘My_controller.php’



class My_controller extends CI_Controller

public function index()


echo “This is my new controller”;






To use this , write following:




How to remove INDEX.PHP from url?

goto config -> config.php -> $config[‘base_url’]=””;



  • remove existing url from this base_url .
  • write your own url in this space.


Example: http://localhost/folder_name


1 Comment
  • Pingback: Data flows in codeigniter | Application flowchart | Tutorial Codeigniter
    Posted at 5:41 am, September 10, 2018

Post a Comment


Optimization WordPress Plugins & Solutions by W3 EDGE