1. codeigniter-first-example

First Example

This example will walk you through a basic "Hello World!" application using CodeIgniter.


The routing syntax for CodeIgniter is as follows:


  1. Create a new file called Hello.php in your CodeIgniter /application/controllers/ directory.

  2. Add the following code to the Hello.php file:

class Hello extends CI_Controller {

  public function index() {
    echo "Hello World!";
  1. Navigate to http://localhost/index.php/hello in your browser.

  2. You should see "Hello World!" displayed on your screen.


This example creates a new controller class called Hello that inherits from the CI_Controller class. The index function in the Hello class simply outputs "Hello World!" to the browser.


This example demonstrates an introduction to CodeIgniter and the basics of creating controllers. Use this example as a starting point for your own CodeIgniter applications.

Important Points

  • CodeIgniter uses a Model-View-Controller (MVC) architecture.
  • URLs are routed using the syntax
  • Controllers are stored in the /application/controllers/ directory.


This example demonstrates a basic "Hello World!" application using CodeIgniter. By creating a new controller class and outputting "Hello World!" to the browser, we are introduced to the basics of CodeIgniter and its routing syntax. Remember that CodeIgniter uses an MVC architecture, and controllers are stored in the /application/controllers/ directory.

Published on: