Codeigniter Interview Questions and Answers

1. What is a hook in CodeIgnitor?

Ans- In Codeigniter, hooks provide a way to change the inner workings of the framework without hacking the core files. In other words, hooks allow you to execute a script with a particular path within the Codeigniter. Usually, it is defined in the application/config/hooks.php file. There are some list of available hooks are given below:

    i. pre_system
    ii. pre_controller
    iii. post_controller_constructor
    iv. post_controller
    v. display_override
    vi. post_system

2. Define Routing in CodeIgniter.

Ans- Routing defines your URLs based on the requirement instead of using the predefined URLs. So, whenever there is a request made that matches the URL pattern defined by us, it will automatically direct to the specified controller and function.

3. Why CodeIgniter is called a loosely based MVC framework?

Ans- Codeigniter is a loosely based MVC Framework because the controller’s classes such as models and views are not mandatory.

4. What is CSRF token in CodeIgniter?

Ans- CSRF stands for Cross-Site Request Forgery. It is a randomly generated value that gets modified with every HTTP request sent by Webform.

5. How to add or load a model in CodeIgniter?

Ans- In CodeIgniter, models are loaded as well as called inside your controller methods. It has the following syntax:


6. What is a Command-Line Interface(CLI)?

Ans- CLI stands for Command-Line Interface. It is a text-based interface for interacting with computers through a set of commands.

7. What are the sessions in CodeIgniter? How to handle sessions in CodeIgniter?

Ans- In CodeIgniter, you are allowed to maintain a user’s “state” by Session class and keep an eye on their activity while they browse your website.

Step-1: Loading a session in CodeIgniter.



Step-2: Read session data in CodeIgniter


Step-3: Create a session in CodeIgniter

$sessiondata = array(
'name_of_user' => 'webeduclick',
'email' => '[email protected]',
'log_state' => TRUE

8. What is the default controller in CodeIgniter?

Ans- The default controller in CodeIgniter is application/config/routes.php.

9. what is an Inhibitor in CodeIgniter?

Ans- Inhibitor is an error handler class, using the native PHP functions like set_exception_handler, set_error_handler to handle parse errors, exceptions, and fatal errors.

10. How can you connect models to a database manually?

Ans- To connect database manually:


11. Define views in CodeIgniter.

Ans- It can be reused by embedding them anywhere in controller file. You can’t call directly access or load in the controller’s file.


12. What is the controller in CodeIgniter?

Ans- In CodeIgniter, Controller is a class file that is named in a way that can be associated with a URI.

13. Define ORM.

Ans- Object-relational mapping (ORM) is a programming technique to convert data from incompatible type systems using object-oriented programming languages.

14. What is a helper file in Codeigniter?

Ans- In Codeigniter, a helper file is a simple procedural function. Each helper function performs one specific task, with no dependence on other functions.

15. How do you remove index.php from the URL in Codeigniter?

Ans- Step-1: Open config.php and replaces.

Step-2: Change your .htaccess file.

Leave a Reply

Your email address will not be published. Required fields are marked *