Javatpoint Logo
Javatpoint Logo

CodeIgniter First Example

A controller is set up to handle static pages. A controller is a class that simplifies the work in CodeIgniter.

In a CodeIgniter framework URL a basic pattern is followed.

In the following URL,

http://abc.com/book/novel/

Here, 'book' is the controller class or you can say this is the controller name.

'novel' is the method that is called. It extends to CI_Controller to inherit the controller properties.


An Example to print Hello World

Create file in Controllers

In Controller create a file named "Hello.php". This file will be saved in the Controller folder of your CodeIgniter. Write the following coding.

Here, your controller class is Hello, extends to CI_Controller means they can access the methods and variables defined in the controller class.

$this loads views, libraries and command the framework.

Create file in Views

Create a file named "hello_world.php". Save this file in the View folder of your CodeIgniter. Write the following coding.

Run the Controller file

To run the file, follow the path http://localhost/CodeIgniter/index.php/Hello/

CodeIgniter First Example3
Next TopicCodeIgniter URL





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA