Corporate Training
Request Demo
Click me
Menu
Let's Talk
Request Demo

Codeigniter Interview Questions and Answers for 2 Year Experience

by Anuradha, on Mar 26, 2018 1:05:24 PM

Codeigniter Interview Questions and Answers for 2 Year Experience

Q1. What is the Codeigniter?

Ans: Codeigniter is open source, webapplication a PHP framework. Codeigniter is loosely based on MVC pattern simple framework in php.

Q2. When and who developed Codeigniter?

Ans: The first public version of CodeIgniter was released on February 28, 2006.

Q3. What is the current version of codeigniter?

Ans: The lastest version 2.2.0 till 6-05-2014.

Q4. Explain Application Flow Chart in codeigniter.

Ans: Application flow chart from Codeigniter documentaion:

  • The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.
    The Router examines the HTTP request to determine what should be done with it.
  • If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.
  • Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
  • The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.
  • The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so that on subsequent requests it can be served.

Q5. Explain how you can extend the class in Codeigniter?

Ans: 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 {

}

Q6. What are the features of codeigniter?

Ans:

  • Codeigniter is open source, webapplication framework.
  • Codeigniter is light weight framework.
  • Codeigniter faster than any other farmework.
  • Codeigniter search engine friendly urls generator.
  • Codeigniter is easy exensible.

Q7. List out different types of hook point in Codeigniter?

Ans: Different types of hook point in Codeigniter includes:

  • post_controller_constructor
  • pre_controller
  • post_sytem
  • pre_system
  • cache_override
  • display_override
  • post_controller

Q8. Explain MVC in Codeigniter.

Ans: Model–View–Controller (MVC) is an architecture that separates the representation of information from the user’s interaction with it.

Controller: The Controller serves as an intermediary between the Model, the View. controller mediates input, converting it to commands for the model or view.

Model: The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database.The model consists of application data and business rules.

View: The View is the information that is being presented to a user. A View will normally be a web page.A view can be any output representation of data.

For more detail understanding MVC please read this article What is MVC(Model-View-Controller) Architecture.

Q9. Explain Codeigniter file structure.

Ans:

Application

-cache
-config
-controllers
-core
-errors
-helpers
-hooks
-languages
-logs
-models-
-thirdparty
-view
system
-core
-database
-fonts
-helpers
-language
-libraries

Q10. Explain what is meant by inhibitor in Codeigniter?

Ans: For CodeIgniter, inhibitor is an error handler class that use native PHP functions like set_exception_handler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors.

Q11. What are the hooks in Codeigniter?

Ans: In CodeIgniter, hooks are events which can be called before and after the execution of a program. It allows executing a script with specific path in the CodeIgniter execution process without modifying the core files. For example, it can be used where you need to check whether a user is logged in or not before the execution of controller. Using hook will save your time in writing code multiple times.

There are two hook files in CodeIgniter. One is application/config/hooks.php folder and other is application /hooks folder.

In other language, if you want to run a code every time after controller constructor is loaded, you can specify that script path in hooks.

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

$config[‘enable_hooks’] = TRUE;

Hooks are defined in application/config/hooks.php file.For example

$hook['pre_controller'] = array(

'class'    => 'MyClass',

'function' => 'Myfunction',

'filename' => 'Myclass.php',

'filepath' => 'hooks',

'params'   => array('test', 'test1', 'webs')

);

Q12. Explain what is meant by routing in Codeigniter?

Ans: In CodeIgniter, the way PHP files served is in different rather than accessing it directly from the browser. This process is the called the 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 be automatically direct to the specified controller and the function.

Q13. How you will be add or load an model in the codeigniter?

Ans: Models will be the typically loaded and called from within your controller functions. To load a model you will have to use the following function:

$this->load->model('Model_name');

 

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

Ans: Changing the URL routes has some benefits like:

  • From the SEO point of the view, to make URL SEO friendly and get more user visits
  • Hide some URL element such as the function name, controller name, etc. from the users for the security reasons
  • Provide different functionality to the particular parts of a system

Q15. Which are the helpers in the Codeigniter?

Ans: Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of the functions in a particular category.There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with the files, etc.

Loading a helper file is quite simple using the following function:

$this->load->helper('name');

Q16. Mention which are the security parameter for XSS in the CodeIgniter?

Ans: Codeigniter has got a cross-site scripting hack prevention filter. This filter either runs automatically or you can run it as per item basis, to filter all the POST and COOKIE data that come across.  The XSS filter will target the commonly used methods to trigger JavaScript or other types of code that attempt to hijack cookies or other malicious activity. If it detects any suspicious thing or anything disallowed is encountered, it will convert the data to character entities.

Q17. How can you load the multiple helper files?

Ans: To load multiple helper files, specify them in an array,

$this->load->helper(array('helper1', 'helper2', 'helper3'));

Q18. Explain how you can link images/CSS/JavaScript from a view in the codeigniter?

Ans: In HTML, there is no Codeigniter way, as such it is a PHP server side framework. Just use an absolute path to your resources to link the images or CSS or JavaScript from a view in CodeIgniter:

/css/styles.css

/js/query.php

/img/news/566.gpg

Q19. Explain CodeIgniter library. How will you load it?

Ans: CodeIgniter provides a rich set of libraries. It is an essential part of CodeIgniter as it increases the developing speed of an application. It is located in the system/library.

It can be loaded as follows;

$this->load->helper(array('helper1', 'helper2', 'helper3'));

Q20. Mention what is the default URL pattern used in Codeigniter framework?

Ans: Codeigniter framework URL has four main components in default URL pattern.  First we have the server name and next we have the controller class name followed by controller function name and function parameters at the end. Codeigniter can be accessed using the URL helper. For example: http://servername/controllerName/controllerFunction/parameter1/parameter2.

Related Interview Questions...

Topics:Codeigniter interview questions and answers for 2Information Technologies (IT)

Comments

Subscribe

Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle

More...