Ans: Codeigniter is open source, webapplication a PHP framework. Codeigniter is loosely based on MVC pattern simple framework in php.
Ans: The first public version of CodeIgniter was released on February 28, 2006.
Ans: The lastest version 2.2.0 till 6-05-2014.
Ans: Application flow chart from Codeigniter documentaion:
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 {
}
Ans:
Ans: Different types of hook point in Codeigniter includes:
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.
Ans:
Application
-cache
-config
-controllers
-core
-errors
-helpers
-hooks
-languages
-logs
-models-
-thirdparty
-view
system
-core
-database
-fonts
-helpers
-language
-libraries
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.
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')
);
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.
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');
Ans: Changing the URL routes has some benefits like:
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');
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.
Ans: To load multiple helper files, specify them in an array,
$this->load->helper(array('helper1', 'helper2', 'helper3'));
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
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'));
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...