can pass variable as the second parameter  of the load->view function. Example:

$data[‘title’]=”My web page”; $data[‘tsp’]=”ussl”;


  1. Which configuration file is used to autoload resources?

Ans: autoload.php file in system/configuration/config.

  1. Discuss the php closing tag is codeigniter.

Ans: In codeigniter the php closing tag is optional. If used, any whitespace after the PHP closing tag can result in PHP errors, warning or even blank pages.

  1. Discuss class, method and variable naming rules in codeigniter.

And: In codeigniter, CLASS name should always have their first letter in uppercase and the rest of the name in lowercase. The class and constructor method should have identical names.

Variable name should always contain lowercase letters, should use underscore separator to separate words and not use camel casing.

  1. Why short opening tags is not allowed in codeigniter?

Ans: Sometimes in php configuration file, short opening  tags is disabled. That’s why CI does not permit short opening tags.

  1. Disacuss the codeigniter URI.

Ans: CodeIgniter URLs use Uniform Resource Identifiers (URI). Here is a typical CodeIgniter URL:http://mywebsite.ext/index.php/controller/method/parameters

Everything after the index.php segment is used by CodeIgniter to determine what to load. The first segment is the name of the Controller. The second segment is used to determine which function to load—if this is blank then the index function will be used. The final segment will be used to pass any data to the function.

  1. What is the function of helper files? From where you can load helper files? How to load helper files?

And: Helper files are a collection of functions in a particular group. Helper can be load from model, view and controller. To load helper file we use  $this->load->helper(‘filename’);

  1. What is plugin? How to load plugin?

Ans: Plugins work in almost exactly the same way as Helpers. The main difference is that a plugin should be used to add a single function, instead of a collection of functions. Plugins are stored inside the system/application/plugins/ folder.

To load pluging we use $this->load->plugin(‘name’);

  1. How to remap function calls?

Ans: We can remap function calls by using a function in our controller called _remap()—this will be called every time that the controller is called, even if a different function is used.

Chapter 2:
1. What is a library? What do library do?

Ans: A CodeIgniter library is simply a class file that abstracts functionality into easy-to-use functions that take much of the strain off the developer. Libraries abstract out functionality for developers and make it easy to re-use code.
2. Discuss benchmark class.

Ans: The Benchmarking Class is used to calculate the time between two points in our application.
3. Discuss input and security class.

Ans: The Input and Security Class sanitizes all global data and filters all POST and COOKIE data to ensure that only alphanumeric characters are present.
4. How to set automatic filtering in CI?

Ans: We can turn on XSS filtering all of the time and filter everything that comes through the library by changing the following line in the system/application/config/config.php file from:

$config[‘global_xss_filtering’] = FALSE;


$config[‘global_xss_filtering’] = TRUE;
5. How to retrieve get, post, cookie or server data in CI?

Ans: Retrieving POST data:

To retrieve post data, we should use the function shown next. The first parameter is the name of the POST item that we are looking for.


Retrieving GET data:

The function for retrieving GET data is identical to the POST function, except that it only retrieves GET data.

$this->input->get(‘some_field’, TRUE);

Retrieving COOKIE data:

This function is the same as those listed previously, but will only look in the COOKIE data.

$this->input->cookie(‘some_field’, TRUE);

Retrieving SERVER data:

This function is the same as the previous examples, except it only returns SERVER data.

$this->input->server(‘some_field’, TRUE);
6. What values are stored in a session by default?

Ans: A CodeIgniter session is simply an array containing the following data:

The user’s unique Session ID (this is a randomly-generated number, which is hashed with MD5 for portability, and is regenerated every five minutes)

The user’s IP address

The user’s User Agent string

The “last activity” timestamp.
7. How to add session data and retrieve session data.

Ans: To add data to the session array, we would use the code given next:

$data = array(

‘username’ => ‘joebloggs’,

’email’ => ‘’,

‘logged_in’ => TRUE



To retrieve session data we use: $this->session->userdata(‘username’);
8. How to unset and distroy session data.

To remove a single session item—the username, for example—we would use the following function:


To destroy a session completely, we would use the following function:


Chapter 3:Form validation and database interaction

  1. Why should we need to validate form? How to load the form validation library?

Ans: We should need to validate form for following reason:

  1. Prevent stored any information directly in a database.
  2. We can limit the types of data being allowed in our forms.
  3. Makes easy to re-populate our form fields.
  4. To show individual errors for each field.
  5. Making the overall end user experience better.
  6. To stop people abusing our form.

To load the form validation library. we can do this in one line, by passing an array to the load->library function.

$this->load->library(array(’email’, ‘form_validation’));
2. List some form validation rules.

Ans. The following rules are readily available for use:

  1. required
  2. matches[field_name]
  3. min_length[x]
  4. max_length[x]
  5. exact_length[x]
  6. alpha
  7. alpha_numeric
  8. alpha_dash
  9. numeric
  10. integer
  11. is_natural
  12. is_natural_no_zero
  13. valid_email
  14. valid_emails
  15. valid_ip
  16. valid_base64
  17. What is callback function? How to call callback function in CI.

Ans. A callback is simply a function in our Controller code that is used in place, or along with, a rule.

We add callback function like following:

$this->form_validation->set_rules(’email’, ‘Email Address’,


The rule callback_add_user—will run the e-mail through the function add_user() in our controller.

Chapter 4: User authentication:

  1. How to use anchor in codeigniter?

Ans: Anchor creates a standard HTML anchor link based on our local site URL:

<a href=””>Click Here</a>

The tag has three optional parameters:

anchor(uri segments, text, attributes)

The first parameter can contain any segments we wish appended to the URL.

Chapter 6: Application Security

  1. What is URI? How to get URI link in CI?

Ans: A URI means Uniform Resource Identifier. it is everything that  comes after our web address.When using CodeIgniter, we  will have a URI that looks like this:


We can get the URI string by using PHP quite simply as follows:


echo $uri;
2. Discuss the URI ‘index.php/controller/method/parameters’?

Ans: Everything after the index.php segment is used by CodeIgniter to determine what to load. The first segment is the name of the Controller. The second segment is used to determine which function to load—if this is blank then the index function will be used. The final segment parameters will be used to pass any data to the function.
3. What’s the difference between URI and QUERY String in codeigniter.


URI Strings :URI Strings are more search engine friendly and also more readable for our site’s visitors

QueryString: Query String is  a older based style that is not easy to read and nor user friendly.

  1. Why does codeigniter restrict URI characters?

Ans:There are a few reasons as to why CodeIgniter restricts:

To avoid asterisk (*) or quotations—either single quotes or double quotes.

sanitize all parameters that are passed to all functions where we accept them.

The controller and model segments that are not allowed in a PHP class name or function name.

  1. What is hash? Name two popular hashing algorithm?

Ans: Hashing is a strong security way to store a user password. Like encoding, hashing values cannot be decoded.

Two popular hashing algorithm:MD5 and Sha1

  1. What is salting?

The salting is a process of adding a string with  a password to change its end hash, which will be completely different from the original password hash.


$salt = ‘123456789987654321’;

$password = ‘password’;

$hash = sha1($salt . $password);

  1. Discuss query building?

Ans:Query binding allows we to write a query and bind certain values to it for later use.
8. What is Cross-site scripting?

Ans: Cross-site scripting (XSS) is a way of injecting malicious JavaScript code into our browser. It also used to hijack a user’s cookie.

Chapter 8: Web Services
1. What is web service?

And: “a software system designed to support interoperable machine-to-machine interaction over a network”.For example: RSS

  1. What is RPC?

Ans: Means Remote Procedure Call. It’s a web service that  provide a set of functions that interface to the application directly. XML-RPC is a specification and a set of implementations that allows software to communicate with a server by using the XML as the request.

  1. What is RESTful web service?

Ans: REST means Representational State Transfer. REST is a method which, rather than defining functions that can be used in applications, defines a resource—a URI—to be used to perform actions on. In CI, web service can be developed using REST.


Leave a comment

Your email address will not be published. Required fields are marked *