CodeIgniter Interview Questions and Answers

Q1. What is CodeIgniter Framework?

Ans. CodeIgniter is one type of Open source PHP framework which we can use for web development like e-commerce website, portal, CRM etc. CodeIgniter framework is based on MVC(Model View Controller) pattern and this framework developer very easily learn and understand because if you understand Class, Object, Function, Inheritance and some CodeIgniter configurations and file structure. Use of CodeIgniter you can develop the best website with less security and clean code.

Q2. What is File structure of CodeIgniter Framework?

Ans. Here, I’m going to define CodeIgniter file structure such as-

  • Application
    • Config
    • Controllers
    • Core
    • Helpers
    • Hooks
    • Language
    • Libraries
    • Logs
    • Models
    • Third_party
    • Views
    • Index.php
  • Documentation
  • System
    • Core
    • Database
    • Fonts
    • Helpers
    • Language
    • Libraries
  • User_guide
  • index.php
  • composer.json
  • .htaccess

Above i explain file structure and application folder is the main folder of CodeIgniter framework and in application folder Config, Controllers, Models, Views this folder are very useful in CodeIgniter.

Q3. Use of Hooks in CodeIgniter Framework?

Ans. In codeIgniter If you want any inner working changes by using hooks behavior without hacking core file on particular action that is called hooks in CodeIgniter. If you want going use this so first of all you need enable hook from config file then you can write your own logic on hooks folder by creating file after that you need to configure this file path with hook behavior in hook.php on config folder.

Q4. What is Inhibitor in CodeIgniter Framework?

Ans. In CodeIgniter Inhibitor means Exception handling methods, Inhibitor is an error handler class that uses for native PHP functions like set_exception_handler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors. Use inhibitor class you can handle the exception and error in codeIgniter.

Q5. Types of Hooks in CodeIgniter?

Ans. In CodeIgniter If you want any inner working changes by using hooks behavior without hacking core file on particular action that is called hooks in codeIgniter.
pre_system- Called very early during system execution.
pre_controller -Called immediately prior to any of your controllers being called.
post_controller_constructor- Called immediately after your controller is instantiated, but prior to any method calls happening.
post_controller- Called immediately after your controller is fully executed.
display_override- Overrides the _display() method.
cache_override- Enables you to call your own method instead of the _display_cache() method in the Output Library. This permits you to use your own cache display mechanism.
post_system- Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.

Q6. What is Library in CodeIgniter?

Ans. The CodeIgniter provides a rich set of libraries. It is an essential part of CodeIgniter as it increases the developing speed of a project. It is located in the “system/libraries and application/libraries”. If you want going to create a class then open your application folder and then open your libraries folder and create a file such as “Abc.php” and then create Class “Abc”. File name first letter has to be in uppercase letter, like Abc.php and class name first letter should also be in uppercase letter and file name and class name should be same.

$this->load->library(‘abc.php’)

Q7. What is Helper in CodeIgniter?

Ans. If you want to perform any specific task or function and want to use anywhere in your project so you can create a helper and write your function and load in your controller and use as globally anywhere in your view or controller functions. For creating a helper you need to open your application folder and then helpers after that create your helper file such as “abc_helper.php” and then write your function.

Q8. How to create a Session in CodeIgniter?

Ans. Simple you just write like this-
$this->session->set_userdata(‘keyName’,’value’);
Here value may be a string or array.

Q9. How to load Model in CodeIgniter?

Ans. Simple you just write like this-
$this->load->model(‘modelName’
);

Q10. How to load View in CodeIgniter?

Ans. Simple you just write like this-
$this->load->view(‘viewName’,’Data’
);
Here data may be a string or array and data you can use in your view file.

News Reporter
IT Software and web development, Core PHP, JavaScript, JQuery, HTML, CSS, CakePHP, Angularjs, Codeigniter etc.

Leave a Reply

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

error: