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.
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.
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’));
A– To add or load model in CodeIgniter, you have to use the function within your controller function– $this->load->model (‘Model_Name’);
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.
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.
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
A– Inhibitor in CodeIgniter is an error handler class that functions with PHP to handle different errors, exceptions and fatal errors.
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’);
A– The reasons can be divided into three parts namely–
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.