Loading...

codeigniter tutorial

CodeIgniter Your First  Application

Your First application is a simplest application that will display some text on the screen. Its a simple  application for beginners to understand basic syntax and working of codeigniter MVC framework.

Before starting with this tutorial I assume that you already have a CodeIgniter application installed and configured (removed index.php from url), if u r not removed please refer Codeigniter Configuration 

 


step1:

Lets start be making a basic controller class file. Create a new file in the ‘controllers’ directory and name it ‘hello.php’.

step2:

write this following code inside hello.php

<?php  
defined('BASEPATH') OR exit('No direct script access allowed');  
  
class Hello extends CI_Controller {  
      
    public function index()  
    {  
        $this->load->view('hello_world');  
    }  
}  
?>

step3:

Now, create a new file in the ‘views’ directory and name it ‘hello_world.php’.

step4:

Put the following code snippet in ‘hello_world.php’.

<!DOCTYPE html>  
<html>  
    <head>  
        <title>Hello World</title>  
    </head>  
    <body>  
     <p>Hello World!</p>  
    </body>  
</html>

step5:

Now open the following URL in the browser to see the output 

http://localhost/codeigniter/hello