CodeIgniter Interview Questions and Answers

1. What is CodeIgniter ?

Answers : CodeIgniter is open source & powerful framework used for developing web applications on PHP. It is based on MVC(Model, View, Controller) pattern.

2.  What are the features of CodeIgniter ?

Answer :  1. It is an open source framework and free to use.

2. It is extremely light weighted.

3. It is based on MVC(Model, View, Controller) pattern.

4.It has full featured database classes and support for several platforms.

5.Excellent documentation.

3. How you can add or load a model in CodeIgniter ?

Answer :


4.How you can connect models to  database manually ?

Answer :  To connect database manually use following syntax :


5.Explain views in CodeIgniter ?

Answer : View folder contains all the markup files like header,footer, sidebar etc. They can be reused by embedding them anywhere in the controller file. They can’t called directly, they have to be loaded in the controller file.

6. How can you load a view in CodeIgniter ?

Answer :


7. Explain controller in CodeIgniter ?

Answer :  A Controller is the intermediate between models and view to process HTTP request and generates a web page. It is the center of every request on your web application.

8. What is the default controller in CodeIgniter ?

Answer :  The file specified in default controller will be loaded by default .When  no file name is mentioned in the URL. By default, it is welcome.php which is the first page to be seen after installing CodeIgniter.

9. What is the basic CodeIginter URL structure ?

Answer :  Instead of using query-string approach, it uses a segment base approach.

It’s  structure is as follows :

Class represent controller class that need to be invoked.

Function is the method that is called.

Id is any additional segment that is passed to controllers.

10.How will you call a constructor in CodeIgniter ?

Answer : 


11. Explain what are hooks in CodeIgniter ?

Answer : CodeIgniter’s hooks feature provide a way to change the inner working of framework without hacking the core files. In other words, hooks allow you to execute a script with a particular path with in the CodeIgniter. Usually, it is defined in application/config/hooks.php file.

The hoks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file :


12.Explain what helpers in CodeIgniter are and how you can load a helper file ?

Answer : In CodeIgniter, helpers are group of function in a particular category that assist you to perform specific functions. In CodeIgniter, you will find many helpers like URL helpers- helping in creating links, Text helpers- perform various text formatting routines, Cookies- helpers set and read cookies. You can can load helper file using command


13. Explain routing in CodeIgniter ?

Answer : In CodeIgniter, the way PHP files served is different rather than accessing it directly from the browser. This process is called routing. Routing in CodeIgniter gives you freedom to customize the default URL pattern to use our own URL pattern according to the requirement. So, whenever there is a request made and matches our URL pattern it will automatically direct to specified controller and function.

14. Why is there a need to configure the URL routes ?

Answer :  Changing the URL routes has some benfits like from SEO point of view, to make URL SEO friendly and get more user visits hide some URL element such as a function name, controller name, etc. from the users for security reasons provide different functionality to particular parts of a system.

15. List out different  types of hook point in CodeIgniter ?

Answer : Different types of hook point in CodeIgniter includes















16.Explain what is inhibitor in CodeIgniter ?

Answer :  For CodeIgniter, inhibitor is an error handler class, using the native PHP functions like set_exception_hnadler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors.

17. Explain how you can extend the class in CodeIgniter ?

Answer :  To extend the native input class in CodeIgniter, you have to build a file named application/core/MY_Input.php and declare your class with

Class MY_Input extends CI_Input

18.Explain how you can enable CSRF in CodeIgniter ?

Answer :  You can activate CSRF (Cross Site Request Forgery) protection in CodeIgniter by operating application/config/config.php file and setting it to $config[‘csrf_protection’]=TRUE; If the form helper, the from_open() function will insert a hidden csrf field in your forms automatically.

19. In which language CodeIgniter is written ?

Answer :   PHP

20. How to access config variable in CodeIgniter ?

Answer :


21. How to unset session in CodeIgniter ?

Answer :


22. How do you get last insert id in CodeIgniter ?

Answer :


Anuj Kumar

This is Anuj Kumar. I’m a professional web developer with 4+ year experience. I write blogs in my free time. I love to learn new technologies and share with others.
I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials.

Recommended Tutorials for you

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.