Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

CodeIgniter Interview Questions

A list of top frequently asked CodeIgniter interview questions and answers are given below.

1) What is CodeIgniter?

CodeIgniter is an open source and powerful framework used for developing web applications on PHP. It is loosely based on MVC pattern and similar to Cake PHP. It is very easy to use compare to other PHP frameworks.

2) What are the most prominent features of CodeIgnitoe?

A list of most prominent features of CodeIgniter:

  • It is an open source framework and free to use.
  • It is extremely light weighted.
  • It is based on Model View Controller (MVC) pattern.
  • It has full featured database classes and support for several platforms.
  • It is extensible. You can easily extend the system by using your own libraries, helpers etc.
  • Excellent documentation.

3) Explain the folder structure of CodeIgniter?

If you download and unzip CodeIgniter, you will get the following file structure/folder structure:


  • cache
  • Config
  • Controllers
  • core
  • errors
  • helpers
  • hooks
  • language
  • libraries
  • logs
  • models
  • thirdparty
  • views


  • core
  • database
  • fonts
  • helpers
  • language
  • libraries


4) How can you add or load a model in CodeIgniter?

To load models in controller functions, use the following function:

$this>load>model (‘Model_Name’);

5) What are hooks in CodeIgniter?

Hook is a feature in CodeIgniter that provides a way to change the inner working of the framework without hacking the core files. It facilitates you to execute a script with a particular path within the CodeIgniter. Usually, it is defined in application/config/hooks.php file.

6) What is helper in CodeIgniter? How can you load a helper file?

Helpers are the group of functions in a particular category that assist you to perform specific functions.

In CodeIgniter, there are many helpers like:

URL Helpers: helping in creating links.

Text Helpers: perform various text formatting routines.

Cookies Helpers: set and read cookies.

To load helper file, use the following command:

$this>load>helper (‘name’);

7) What is routing in CodeIgniter?

Routing specifies the way how PHP files served in CodeIgniter. It is different rather than accessing it directly from the browser. Routing facilitates you to customize the default URL pattern and use our own URL pattern according to the requirement. So, whenever there is a request made and matches your URL pattern it will automatically routed to the specified controller and function.

8) What is the need to configure the URL routes?

URL routes are changed for some benefits:

From SEO point of view: It makes URL SEO friendly and get more user visits.

You can hide some URL element such as a function name, controller name, etc. from the users for security reasons.

It provides different functionality to particular parts of a system.

9) What are the different types of hook point in CodeIgniter?

A list of different types of hook point in CodeIgniter:

  • post_controller_constructor
  • pre_controller
  • post_sytem
  • pre_system
  • cache_override
  • display_override
  • post_controller

10) What is inhibitor in CodeIgniter?

In CodeIgniter, Inhibitor is an error handler class that uses native PHP functions like set_exception_handler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors.

11) How can you extend the class in CodeIgniter?

You have to build a file name application/core/MY_Input.php and declare your class with Class MY_Input extends CI_Input {}to extend the native input class in CodeIgniter.

12) What are the security parameters for XSS in CodeIgniter?

There are some cross-site scripting hack prevention filters in CodeIgniter. These filters either run automatically or manually, as per item basis to filter all POST and COOKIE data that came across. The XSS filters target the commonly used methods to trigger JavaScript or other types of code that attempt to hijack cookies or other malicious activity. If it finds any suspicious thing or anything disallowed is encountered, it converts the data to character entities.

13) How can you prevent CodeIgniter from CSRF (Cross Site Request Forgery)?

There are several ways to prevent CodeIgniter from CSRF.

The most used method is that use a hidden field in each form on the website. This hidden field is referred as CSRF token. It is a random value that alters with each HTTP request sent. As soon as it is inserted in the website forms, it gets saved in the user’s session as well. So, when the form is submitted by the users, the website checks whether it is the same as the one saved in the session. If it is same then, the request is valid.

14) How can you enable CSRF in CodeIgniter?

You can enable CSRF protection in CodeIgniter by operating your application/config/config.php file and setting it to

$config [‘csrf_protection’] = TRUE;

If you avail the form helper, the form_open() function will insert a hidden CSRF field in your forms automatically.

15) How can you print SQL statement in CodeIgniter model?