Explain What Is Codeigniter?
Codeigniter is an open source framework for web application. It is used to develop websites on PHP. It is loosely based on MVC pattern, and it is easy to use compare to other PHP framework.
Explain What Are Hooks In Codeigniter?
Codeigniter’s hooks feature provides a way to change the inner working of the framework without hacking the core files. In other word, hooks allow you to execute a script with a particular path within the Codeigniter. Usually, it is defined in application/config/hooks.php file.
The hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
$config[‘enablehooks’] = TRUE;
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.
Mention What Is The Default Url Pattern Used In Codeigniter Framework?
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.
Explain How You Can Extend The Class In Codeigniter?
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 {
}
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. If it is same then, the request is legitimate.
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.
What Is Stable Version Of Codeigniter?
Version: 3.0.5,
Date January 13, 2016
In Which Language Codeigniter Is Written?
PHP
What Are The Security Parameter For Xss In Codeigniter?
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 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.
Who Developed Codeigniter?
Codeigniter was developed by ellislab Inc.
Why Codeigniter Is Called As Loosely Based Mvc Framework?
Reason behind this is we does not need to follow strict mvc pattern while creating application.We can also able to build with model only view and controllers are enough to built a application.
Explain How You Will Load Or Add A Model In Codeigniter?
Within your controller functions, models will typically be loaded; you will use the function
$this->load->model (‘Model_Name’);
Explain What Helpers In Codeigniter Are And How You Can Load A Helper File?
In CodeIgniter, helpers are group of function in a particular category that assist you to perform specific functions. In CodeIgniter, you will find many helpers like URL helpers- helping in creating links, Text helpers- perform various text formatting routines, Cookies- helpers set and read cookies. You can load helper file by using command $this->load->helper (‘name’) ;
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.
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.
List Out Different Types Of Hook Point In Codeigniter?
Different types of hook point in Codeigniter includes:
post_controller_constructor
pre_controller
post_sytem
pre_system
cache_override
display_override
post_controller
$hook[‘pre_controller’] = array(
‘class’ => ‘MyClass’,
‘function’ => ‘Myfunction’,
‘filename’ => ‘Myclass.php’,
‘filepath’ => ‘hooks’,
‘params’ => array(‘param1’, ‘param2’, ‘param3’)
);
Mention What Are The Security Parameter For Xss In Codeigniter?
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 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.
Explain How You Can Link Images/css/javascript From A View In Code Igniter?
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 images/CSS/JavaScript from a view in CodeIgniter
/css/styles.css
/js/query.php
/img/news/566.gpg
What Are The Features Of Codeigniter? Open Source Framework?
Light Weight
CodeIgniter is Extensible
Full Featured database classes
How To Access Config Variable In Codeigniter?
$this->config->item(‘variable name’);
How To Unset Session In Codeigniter?
$this->session->unsetuserdata(‘somename’);;
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
Explain Application Flow Chart In Codeigniter?
The following graphic illustrates how data flows throughout the system:
CodeIgniter application flow:
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.
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.
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 Helpers help 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’);
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.
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.
show_error(‘message’ [, int $statuscode= 500 ] )
This function will display the error message supplied to it using template application/errors/errorgeneral.php.
show_404(‘page’ [, ‘logerror’])
This function will display the 404 error message supplied to it using template application/errors/error404.php.
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.
How Do You Use Aliases With Autoloading Models In Codeigniter?
We can auto load model like this:
$autoload[‘model’] = array(array(‘usersmodel’, ‘users’), array(‘newsmodel’, ‘news’), ‘categorymodel’);
How To Get Random Records In Mysql Using Codeigniter?
We can use this:
$this->db->order_by(‘id’,’RANDOM’);
Codeigniter is an open source framework for web application. It is used to develop websites on PHP. It is loosely based on MVC pattern, and it is easy to use compare to other PHP framework.
Explain What Are Hooks In Codeigniter?
Codeigniter’s hooks feature provides a way to change the inner working of the framework without hacking the core files. In other word, hooks allow you to execute a script with a particular path within the Codeigniter. Usually, it is defined in application/config/hooks.php file.
The hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
$config[‘enablehooks’] = TRUE;
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.
CodeIgniter Freshers Interview Questions Answers |
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.
Explain How You Can Extend The Class In Codeigniter?
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 {
}
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. If it is same then, the request is legitimate.
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.
What Is Stable Version Of Codeigniter?
Version: 3.0.5,
Date January 13, 2016
In Which Language Codeigniter Is Written?
PHP
What Are The Security Parameter For Xss In Codeigniter?
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 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.
Who Developed Codeigniter?
Codeigniter was developed by ellislab Inc.
Why Codeigniter Is Called As Loosely Based Mvc Framework?
Reason behind this is we does not need to follow strict mvc pattern while creating application.We can also able to build with model only view and controllers are enough to built a application.
Explain How You Will Load Or Add A Model In Codeigniter?
Within your controller functions, models will typically be loaded; you will use the function
$this->load->model (‘Model_Name’);
Explain What Helpers In Codeigniter Are And How You Can Load A Helper File?
In CodeIgniter, helpers are group of function in a particular category that assist you to perform specific functions. In CodeIgniter, you will find many helpers like URL helpers- helping in creating links, Text helpers- perform various text formatting routines, Cookies- helpers set and read cookies. You can load helper file by using command $this->load->helper (‘name’) ;
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.
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.
List Out Different Types Of Hook Point In Codeigniter?
Different types of hook point in Codeigniter includes:
post_controller_constructor
pre_controller
post_sytem
pre_system
cache_override
display_override
post_controller
$hook[‘pre_controller’] = array(
‘class’ => ‘MyClass’,
‘function’ => ‘Myfunction’,
‘filename’ => ‘Myclass.php’,
‘filepath’ => ‘hooks’,
‘params’ => array(‘param1’, ‘param2’, ‘param3’)
);
Mention What Are The Security Parameter For Xss In Codeigniter?
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 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.
Explain How You Can Link Images/css/javascript From A View In Code Igniter?
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 images/CSS/JavaScript from a view in CodeIgniter
/css/styles.css
/js/query.php
/img/news/566.gpg
What Are The Features Of Codeigniter? Open Source Framework?
Light Weight
CodeIgniter is Extensible
Full Featured database classes
How To Access Config Variable In Codeigniter?
$this->config->item(‘variable name’);
How To Unset Session In Codeigniter?
$this->session->unsetuserdata(‘somename’);;
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
Explain Application Flow Chart In Codeigniter?
The following graphic illustrates how data flows throughout the system:
CodeIgniter application flow:
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.
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.
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 Helpers help 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’);
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.
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.
show_error(‘message’ [, int $statuscode= 500 ] )
This function will display the error message supplied to it using template application/errors/errorgeneral.php.
show_404(‘page’ [, ‘logerror’])
This function will display the 404 error message supplied to it using template application/errors/error404.php.
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.
How Do You Use Aliases With Autoloading Models In Codeigniter?
We can auto load model like this:
$autoload[‘model’] = array(array(‘usersmodel’, ‘users’), array(‘newsmodel’, ‘news’), ‘categorymodel’);
How To Get Random Records In Mysql Using Codeigniter?
We can use this:
$this->db->order_by(‘id’,’RANDOM’);
Post a Comment