Sunday, November 23, 2014

Codeigniter interview questions and answers

1- What is codeigniter? 
CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.
2- What are the features of codeigniter?
  1. Codeigniter is free to use,its an open source framework.
  2. Model-View-Controller Based System.
  3. Extremely Light Weight.
  4. Full Featured database classes with support for several platforms..
  5. CodeIgniter is Extensible.The system can be easily extended through the use of your own libraries, helpers, or through class extensions or system hooks.
  6. Excelent documentation.
  7. Full Featured database classes with support for several platforms,Security and XSS Filtering,Error Logging.
3- Explain Codeigniter File Structure?
following are the folder structure :-
  • application
    • cache
    • Config
    • Controllers
    • core
    • errors
    • helpers
    • hooks
    • language
    • libraries
    • logs
    • models
    • thirdparty
    • views
  • system
    • core
    • database
    • fonts
    • helpers
    • language
    • libraries
4- Explain Application Flow Chart in codeigniter?
The following graphic illustrates how data flows throughout the system:
CodeIgniter application flow
  1. The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.
  2.  The Router examines the HTTP request to determine what should be done with it.
  3. If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.
  4.  Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
  5. The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.
  6. 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.
5- Explain MVC in Codeigniter?
CodeIgniter is based on the Model-View-Controller development pattern. MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.
  • 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 View is the information that is being presented to a user.
    A View will normally be a web page, but in CodeIgniter, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of "page".
  • The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.
6- What are the hooks in codeigniter?
CodeIgniter's Hooks feature provides a means to tap into and modify the inner workings of the framework without hacking the core files. When CodeIgniter runs it follows a specific execution process, diagramed in the Application Flow page. There may be instances, however, where you'd like to cause some action to take place at a particular stage in the execution process. For example, you might want to run a script right before your controllers get loaded, or right after, or you might want to trigger one of your own scripts in some other location.
The hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
$config['enablehooks'] = TRUE;
7. How you will load an model in codeigniter?
$this->load->model('Modelname');
8- What are the helpers in codeigniter?
Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of 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 Helpershelp you deal with files, etc.
Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions.
Loading a helper file is quite simple using the following function:
$this->load->helper('name');
9- How you will use or add codeigniter libraries?
When we use the term "Libraries" we are normally referring to the classes that are located in the libraries directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create your own libraries within your application/libraries directory in order to maintain separation between your local resources and the global framework resources.
10. How you will work with error handling in codeigniter?
CodeIgniter lets you build error reporting into your applications using the functions described below. In addition, it has an error logging class that permits error and debugging messages to be saved as text files.
showerror('message' [, int $statuscode= 500 ] )
This function will display the error message supplied to it using template application/errors/errorgeneral.php.
show404('page' [, 'logerror'])

This function will display the 404 error message supplied to it using template application/errors/error404.php.
logmessage('level', 'message')

This function lets you write messages to your log files. You must supply one of three "levels" in the first parameter, indicating what type of message it is (debug, error, info), with the message itself in the second parameter.

Note: This article is taken from "http://www.programmerdesk.com/blog/detail/33/Codeigniter-interview-questions-and-answers#.VHGxcouUfkU" 

No comments:

Post a Comment

Please Comment Here!

How to backup and download Database using PHP

< ?php $mysqlUserName = 'databaseusername' ; $mysqlPassword = 'databasepassword' ; $mysqlHostNa...