Interview questions about Igniter
1. What is Code Igniter?
CodeIgniter is an open source and powerful framework used for developing web applications on PHP. It is loosely based on MVC pattern and similar to Cake PHP. CodeIgniter contains libraries, simple interface and logical structure to access these libraries, plug-ins, helpers and some other resources which solve the complex functions of PHP more easily maintaining high performance. It simplifies the PHP code and brings out a fully interactive, dynamic website at a much shorter time.
2. What are the most prominent features of Code Igniter?
A list of most prominent features of Code Igniter:
o It is an open source framework and free to use.
o It is extremely light weighted.
o It is based on the Model View Controller (MVC) pattern.
o It has full featured database classes and support for several platforms.
o It is extensible. You can easily extend the system by using your libraries, helpers.
o Excellent documentation.
3. 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
4. List out different types of hook point in Code igniter?
Different types of hook point in Codeigniter includes
5. Explain MVC in CodeIgniter?
CodeIgniter framework is based on MVC pattern. MVC is a software that gives you a separate logical view from the presentation view. Due to this, a web page contains minimal scripting.
o Model – The Controller manages models. It represents your data structure. Model classes contain functions through which you can insert, retrieve or update information in your database.
o View – View is the information that is presented in front of users. It can be a web page or parts the page like header and footer.
o Controllers – Controller is the intermediary between models and view to process HTTP request and generates a web page. All the requests received by the controller are passed on to models and view to process the information.
6. Explain views in Code Igniter?
View folder contains all the markup files like header, footer, sidebar, etc. They can be reused by embedding them anywhere in controller file. They can’t call directly, and they have to be loaded in the controller’s file.
Create a file and save it in application/views folder. For example, we have created a file Firstview.php.
7. Mention what are the security parameter for XSS in Code Igniter?
9. Explain what is inhibitor in Code Igniter?
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.
10. Explain controller in Code Igniter?
A controller is the intermediary between models and views to process the HTTP request and generates a web page. It is the center of every request on your web application.
11. What is an inhibitor of Code Igniter?
In CodeIgniter, Inhibitor is an error handler class that uses native PHP functions like set_exception_handler, set_error_handler, register_shutdown_function to handle parse errors, exceptions, and fatal errors.
12. What is the default method name in Code Igniter?
By default controller always calls index method. If you want to call a different method, then write it in the controller?s file and specify its name while calling the function.
13. 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.
14. Explain how you can enable CSRF (Cross Site Request Forgery) in Code Igniter?
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. What is routing in Code Igniter?
• Routing is a technique used in CodeIgniter, by which you can define your URLs based on the requirement instead of using the predefined URLs. So, whenever there is a request made and matches the URL pattern defined by us, it will automatically direct to the specified controller and function.
• A URL string and its corresponding controller class or method are in a one-to-one relationship here. The URI segments usually follow this pattern: example.com/class/function/id/. All routing rules are defined in theapplication/config/routes.php file of CodeIgniter.
16. What are drivers in CodeIgniter?
• A driver is a type of library that has a parent class and multiple child classes. These child classes can access their parent class, but they can’t access their siblings.
• Drivers can be found in the system/libraries folder.
• There are three steps for creating a driver:
o Making file structure
o Making driver list
o Making driver(s)
17. How to link images from a view in Code Igniter?
leave your comment