In this tutorial you will learn about the CodeIgniter Helloworld Application and its application with practical example.
CodeIgniter Hello World Application
The “Hello world!” application is a simplest application that will display some text on the screen. The “Hello world!” application is simple yet complete application for beginners to understand basic syntax and working of codeigniter MVC framework.
Prerequisites
Before starting with this tutorial I assume that you already have a CodeIgniter application installed and configured (removed index.php from url), in my example I have installed and configured it as –
http://localhost/codeigniter/
Step 1:- Lets start be making a basic controller class file. Create a new file in the ‘controllers’ directory and name it ‘hello.php’.
Step 2:- Put the following code snippet in this controller class –
1 2 3 4 5 6 7 8 9 10 11 |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Hello extends CI_Controller { public function index() { $this->load->view('hello_world'); } } ?> |
Step 3:- Now, create a new file in the ‘views’ directory and name it ‘hello_world.php’.
Step 4:- Put the following code snippet in ‘hello_world.php’.
1 2 3 4 5 6 7 8 9 |
<!DOCTYPE html> <html> <head> <title>Hello World</title> </head> <body> <p>Hello World!</p> </body> </html> |
Step 5:- Now open the following URL in the browser to see the output –
http://localhost/codeigniter/hello
Output :-