Codeigniter interview questions for fresher & expert level
1) Explain what is CodeIgniter?
Codeigniter is an open source framework for web application. It is used to develop websites on PHP. It is loosely based on MVC pattern, and it is easy to use compare to other PHP framework.
2) Explain what are hooks in CodeIgniter?
Codeigniter’s hooks feature provides a way to change the inner working of the framework without hacking the core files. In other word, hooks allow you to execute a script with a particular path within the Codeigniter. Usually, it is defined in application/config/hooks.php file.
$hook['pre_controller'] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('param1', 'param2', 'param3')
3) Explain how you will load or add a model in CodeIgniter?
Within your controller functions, models will typically be loaded; you will use the function
4) Explain what helpers in CodeIgniter are and how you can load a helper file?
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 load helper file by using command $this->load->helper (‘name’) ;[/toggle]
5) Explain routing in Codeigniter?
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 the specified controller and function.[/toggle]
6) Why is there a need to configure the URL routes?
Changing the URL routes has some benefits 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
7) List out different types of hook point in Codeigniter?
Different types of hook point in Codeigniter includes
8) Mention what are the security parameter for XSS in CodeIgniter?
10) Explain what is inhibitor in CodeIgniter?
For CodeIgniter, inhibitor is an error handler class, using the native PHP functions like set_exception_handler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors.