Codeigniter Interview Questions and Answers for 1-2 year experiance. This is very usefull for Experience Persion. This is best Codeigniter Interview Question Answer
Here is Codeigniter Interview Questions and Answers for 1-2 year experiance
Codeigniter is open source , web application framework.Its is for building websites using php.Codeigniter is loosely based on MVC pattern. Most simple framework in php , which is you will easily learn.Its mostly known for its speed as compare to other frameworks in php.
Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries.
2. When and who developed codeigniter.
The first public version of CodeIgniter was released on February 28, 2006.
3. What is current version of codeigniter.
version 2.2.0 was released June 2014.The development version of codeigniter 3.0-dev was release on October 20, 2011.Preview version 3.0-dev, is certified open source software licensed with the Open Software License.
4. What are the features of codeigniter.
- Codeigniter is free to use,its an open source framework.
- Its light weight.The core system requires only a few very small libraries.Not like other frameworks that require heavy file libraries.
- CodeIgniter is Fast.Its faster than any other framework in php.
- The URLs generated by CodeIgniter are clean and search-engine friendly.You will change any url to what ever you want from files.
- CodeIgniter is Extensible.The system can be easily extended through the use of your own libraries, helpers, or through class extensions or system hooks.
- CodeIgniter Uses MVC(Model View Controller) which allows great separation between logic and presentation.
- CodeIgniter requires nearly zero configuration,does not require you to use the command line,not forced to learn a templating language.
- Full Featured database classes with support for several platforms,Security and XSS Filtering,Error Logging.
5. Explain Codeigniter File Structure.
When you download Codeigniter you will see the following folder structure :-
6. Explain Application Flow Chart in codeigniter.
- 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.
7. Explain MVC in Codeigniter.
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.
8. 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.How ever you like to cause some action to take place at a particular stage in the execution process. In other word, hooks allow you to execute a script with a particular path within the Codeigniter.
The 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
In the above example hook ‘pre_controller‘ is called hook point. There are many different types of hook point in Codeigniter which is below-
9. How you will add or load an model in codeigniter.
Models will typically be loaded and called from within your controller functions. To load a model you will use the following function:
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 Helpers help you deal with files, etc.
Loading a helper file is quite simple using the following function:
11. How you will use or add codeigniter libraries.
All of the available libraries are located in your system/libraries folder. In most cases, to use one of these classes involves initializing it within a controller using the following initialization function:-
12. How you will work with error handling in codeigniter.
CodeIgniter lets you build error reporting into your applications using the functions:-
- show_error():- This function will display the error message supplied to it using template application/errors/error_general.php.
- show_404() :- Function will display the 404 error message.
- log_message(‘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.
13. What are the security parameter for XSS in CodeIgniter?
14. Explain how you can enable CSRF (Cross Site Request Forgery) in CodeIgniter?
You can activate CSRF (Cross Site Request Forgery) protection in CodeIgniter by operating your application/config/config.php file and setting it to
$config [ ‘csrf_protection’] = TRUE;
If you avail the form helper, the form_open() function will insert a hidden csrf field in your forms automatically.
15. Explain how you can prevent CodeIgniter from CSRF?
There are several ways to protect CodeIgniter from CSRF, one way of doing is to use a hidden field in each form on the website. This hidden field is referred as CSRF token; it is nothing but a random value that alters with each HTTP request sent. As soon as it is inserted in the website forms, it gets saved in the user’s session as well. So, when the form is submitted by the users, the website checks whether it is the same as the one saved in the session. If it is same then, the request is legitimate.
16. Explain what is inhibitor in CodeIgniter?
For CodeIgniter, inhibitor is an error handler class, using the native PHP functions like set_exception_handler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors.
17. Explain routing in Codeigniter?
In CodeIgniter, the way PHP files served is different rather than accessing it directly from the browser. This process is called 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 automatically direct to the specified controller and function.
18. Why is there a need to configure the URL routes?
Changing the URL routes has some benefits like
- From SEO point of view, to make URL SEO friendly and get more user visits
- Hide some URL element such as a function name, controller name, etc. from the users for security reasons
- Provide different functionality to particular parts of a system.