Top CodeIgniter Interview Questions


Best CodeIgniter Interview Questions

SPOTLIGHT

Mar 01, 2017
Sep 26, 2016

It does not matter how brilliant student you are, it is the interview that decides the fate. So, it is needless to say that prior preparation for every interview is crucial and if you are one of the web developers, we have something for you. Here, we will be sharing top CodeIgniter interview questions and answers, which is an important allocation for the web world. Keep reading.

Q1. What is CodeIgniter and what are the features of CodeIgniter? Explain.

A– CodeIgniter, an open source framework for a web application, is used to develop websites on PHP and it is loosely patterned on MVC. Amongst many features, CodeIgniter specifically includes three essential features namely lightweight, extensible and it has full featured database classes.

Q2. What are hooks in CodeIgniter and explain different types of hook point in it?

A– The hooks in CodeIgniter help to execute a script to change the inner framework of this web application without changing or hacking the core files. Generally, it is defined in application/config/hooks, PHP files.

The different types of hooks in CodeIgnhiter are as follows–

post_controller_constructor

pre_controller

post_sytem

pre_system

cache_override

display_override

post_controller

$hook[‘pre_controller’] = array(

‘class’ => ‘MyClass’,

‘function’ => ‘Myfunction’,

‘filename’ => ‘Myclass.php’,

‘filepath’ => ‘hooks’,

‘params’ => array(‘param1’, ‘param2’, ‘param3’));

Q3. How can someone add a model in CodeIgniter?

A– To add or load model in CodeIgniter, you have to use the function within your controller function– $this->load->model (‘Model_Name’);

Q4. Explain the concept of routing in CodeIgniter.

A– Unlike another framework, the PHP files in CodeIgniter served in a completely different way rather accessing it directly browser. This is called routing. And the unique feature of CodeIgniter router is that it lets you customise the default URL pattern to use your own URL pattern according to your requirement.

Q5. State the security parameter for XSS in CodeIgniter.

CodeIgniter has got a cross-site scripting filter that prevents hacking, and it automatically runs through every post and cookie data that comes across. This XSS filter commonly targets methods to trigger JavaScript or other types of codes that attempt to hijack cookies. XSS detects this suspicious thing and convert the data into character entity in order to protect them.

Q6. State the way, how one can link an image or CSS or JavaScript from a view in CodeIgniter.

 A– There are no direct ways, only you can use an absolute way to link images/CSS/JavaScript from a view in CodeIgniter.

/css/styles.css

/js/query.php

/img/news/566.gpg

Q7. What is inhibitor in CodeIgniter?

A– Inhibitor in CodeIgniter is an error handler class that functions with PHP to handle different errors, exceptions and fatal errors.

Q8. What is a helper in CodeIgniter and how can someone load a helper file?

A– Helpers in CodeIgniter are a group of functions that assists you to perform certain different functions. There are many helpers available in CodeIgniter such as URL helpers, Text helpers, Cookies helpers, etc. You can load a helper using the command as mentioned below– $this->load->helper (‘name’);

Q9. Why do you need to configure the URL routes in CodeIgniter?

A– The reasons can be divided into three parts namely–

  1. To make it more SEO friendly.
  2. To hide many URL elements such as controller name, function name, etc.
  3. To provide different functionality.

Q10. State how can you prevent CodeIgniter from CSRF?

A– There are several ways to protect CodeIgniter from CSRF, and one of such ways is to use a hidden field in each form on the website named as CSRF token.

banner