Codeigniter interview question LEARNOVITA

CodeIgniter Interview Questions and Answers [ TO GET HIRED ]

Last updated on 26th Sep 2022, Blog, Interview Question

About author

Sanjay (Sr Big Data DevOps Engineer )

Highly Expertise in Respective Industry Domain with 7+ Years of Experience Also, He is a Technical Blog Writer for Past 4 Years to Renders A Kind Of Informative Knowledge for JOB Seeker

(5.0) | 13265 Ratings 1673

1.What is CodeIgniter?

Ans:

CodeIgniter is an associate degree ASCII text file and MVC-based framework used for internet application development on PHP. This framework contains libraries, a neater interface with a logical structure to access these libraries, helpers, plug-ins, and different resources similarly. it’s straightforward to use compared to different PHP frameworks.

2.What area unit hooks in CodeIgnitor?

Ans:

  • CodeIgniter’s hooks can give the simplest way to vary the interior workings or framework functionalities which none would like for hacking the core files. It permits script execution with a specific path inside the CodeIgniter.
  • We can globally enable/disable the hooks feature by setting the below-given item within the application/ config/ config.php file: $config[‘enable_hooks’] = TRUE;
  • It is outlined in application/ config/ hooks.php file.

3.What is the associate degree matter in CodeIgniter?

Ans:

A matter in CodeIgniter is a blunder handler category. It’ll build use of PHP’s native functions like set_error_handler, set_exception_handler, register_shutdown_function to handle dissect errors, exceptions, and fatal errors.

4.How to check the CodeIgniter version?

Ans:

There area unit two ways that to see the CodeIgniter version:

The first technique: is to run the subsequent code You can echo the constant price of CI_VERSION within the CodeIgniter controller or read file.

The second technique: is to navigate to the system/core/CodeIgniter.php directory that stores this version of CodeIgniter during a world constant named ‘CI_VERSION’. Open the file and have a glance at the lines:

5.Explain the distinction between helper and library in CodeIgniter?

Ans:

    HelperLibrary
    Helper could be an assortment of common functions that we will use inside Models, Views similarly as in Controllers. Once we tend to embrace the helper file, we will get access to the functions. Library could be a category that includes a set of performs that allows for making an associate degree instance of that category by the $this->load->library() function.
    It is not written in object-oriented format. It’s written in an associate degree object-oriented format.
    It is known within the same manner you decide PHP functions. you need to produce an associate degree object of the category to decide library functions by exploiting the $this->library_name->method().

6.What is the REST API in Codeigniter?

Ans:

A REST API could be an internet service that uses hypertext transfer protocol strategies like GET, PUT, POST, DELETE for information manipulation over the cross platforms. During this tutorial, I will be able to demonstrate however you’ll be able to produce a REST API in Codeigniter.

7.What area unit drivers in CodeIgniter?

Ans:

A driver could be a kind of library that includes a parent category and multiple kid categories. These kid categories will access their parent category, however they can’t access their siblings.Drivers are found within the system/libraries folder.There area unit 3 steps for making a driver:

  • Making file structure.
  • Making driver list.
  • Making driver(s).

8.How to link pictures from a read in CodeIgniter?

Ans:

In Codeigniter, you’ll be able to link images/CSS/JavaScript from a read by exploitation absolutely the path to the resources needed with regard to the foundation folder as given below:

  • /css/styles.css
  • /js/query.php
  • /img/news/566.gpg

9.Why CodeIgniter is termed a loosely primarily based MVC framework?

Ans:

Codeigniter is termed a loosely primarily based MVC framework as a result of it doesn’t conform to a strict MVC pattern throughout application creation. it’s not necessary to make a model, we will use solely read associate degreed controllers for making an application. Additionally, one will modify CodeIgniter to utilize HMVC(Hierarchical Model read Controller) similarly.

10.What is a helper in CodeIgniter?

Ans:

Helpers are the cluster of functions that are a unit helpful in helping the user to perform specific tasks.There are 3 varieties of helper files. They are:

URL helpers: Used for making the links.

Text helpers: Used for the data format of text.

Cookies helpers: want to scan and manage cookies.

11.Explain CodeIgniter design?

Ans:

  • CodeIgniter is principally designed to deliver high performance in less time inside an honest atmosphere. To achieve this, every developing method is intended in a simplified manner.
  • From the technical purpose of read, it’s dynamically instantiated (libraries area unit loaded solely for the asking that makes it light-weighted), has loose coupling (components rely terribly less on every other), and part singularity (each category and its functions area unit targeted solely on their purpose).
  • Data flow in CodeIgniter: Below image represents that whenever a request is raised from the CodeIgniter application, firstly, it’ll head to the index.php file.
  • index.php is the default file of CodeIgniter. This file initializes the bottom resources.
  • The router determines what ought to be through with the knowledge.
  • If the requested cache file exists, then the knowledge is moved on to the browser and ignores the additional processes.
  • If the page requested by the user doesn’t exist within the caching file, the hypertext transfer protocol request and information submitted are going to be passed underneath the security check.
  • The application controller can load the models, libraries, helpers, plugins, and scripts needed consistent with the request.
  • A read is employed for winning the info from the applying controller that may be portrayed to the user, and that they pass the info to the caching file to the quickest access for future requests.

12.How to load a helper in CodeIgniter?

Ans:

  • You need to load the helper files for exploitation. Once loaded, it’ll be globally accessible to your controller and views. they’ll be obtained at 2 places in CodeIgniter. A helper file is going to be searched by CodeIgniter within the application/helpers folder and if it’s not accessible therein folder then it’ll register the system/helpers folder.
  • Helper file is loaded by adding the subsequent code to the creator of the controller or within any interpreter that wishes to use: $this->load->helper(‘file_name’); Write your file name at the place of file_name.
  • To load address helper we will use the code given below: $this->load->helper(‘url’);
  • You are allowed to auto-load a helper if your application desires that helper globally as well as it within the application/config/autoload.php file.

13.What square measures the benefits of CodeIgniter?

Ans:

Few benefits of victimization CodeIgniter is given below:

Built-in libraries: It comes with numerous kinds of default helpers for multiple things as well as strings, arrays, cookies, directories, file handling, and forms among others.

Data abstraction: you’ll build use of the CodeIgniter information abstraction layer for making, adding, deleting, and commutation statements in an exceedingly hassle-free manner. This framework permits you to manage multiple connections employing a single application.

Active Developer Community: larger the community, the higher the assistance you get. freshly graduated developers expect the framework’s forum to induce their doubts and find out about new things within the method. With numerous individuals actively collaborating in it from around the world, your doubts are going to be solved in a few hours. And because of an equivalent reason, CodeIgniter documentation is ten times larger than the other framework.

14.Give the list of hooks out there in CodeIgniter?

Ans:

The list of accessible hook points square measure given below:

Pre_system: it’s known as ab in it io throughout system execution.

Pre_controller: it’s known as at once before any of the controllers being known as.

Post_controller_constructor: it’s known as before long once instantiating your controller, however before any .

prevalence of the strategy decision. post_controller: it’s known as at once once the whole execution of the controller.

Display_override: It overrides the _display() technique.

Cache_override: It permits line of work of the user-defined technique rather than _display_cache() technique that is accessible within the Output Library. This allows you to victimize your own cache show mechanism.

Post_system: it’s known as before long once the ultimate rendered page has been submitted to the net browser, at the tip of system execution once the ultimate knowledge has been sent to the browser.

15.What is Command-Line Interface(CLI)?

Ans:

Command-Line Interface or CLI could be a text-based interface for interacting with computers through a group of commands.

16.What is a third party in CodeIgniter?

Ans:

So, if you’re victimizing CodeIgniter then you’ve got to place that third party API libraries among an equivalent library folder wherever you’ve got unbroken or created your own application libraries. it’s suggested to put third party packages within the application/third_party folder.

17.What is meant by a library?

Ans:

Libraries square measure packages created in PHP that offer higher-level abstractions and therefore contribute to quicker development. This removes the need of specializing in little, minute details by taking care of these by themselves.

18.How are you able to load a library in CodeIgniter?

Ans:

For example, to load the Shape Validation Library you’d do this: $this->load->library(‘form_validation’); Once initialized you’ll use it as indicated within the user guide page and admire that category.

19.What is the CSRF token in CodeIgniter?

Ans:

CSRF(Cross-Site Request Forgery) token could be an indiscriminately generated value that gets changed with each hypertext transfer protocol request sent by webform.A CSRF attack forces a browser of the logged-on victim for causing a cast hypertext transfer protocol request, as well as the cookie of the victim and different data associated with authorization, to an internet application. A CSRF token is employed for setting or activating the protection in CodeIgniter.

20.How to set a CSRF token?

Ans:

To set CSRF, you’ve got to line the corresponding config worth as true in your application/config/config.php file.

  • Syntax : $config[‘csrf_protection’] = TRUE;

If you employ the shape helper, the form_open() technique can mechanically insert a hidden CSRF field in your forms.

21.How to extend the category in CodeIgniter?

Ans:

You have to form a file with the name Example.php underneath application/core/ directory and declare your category with the below code:

  • Class Example extends CI_Input.

22.What is the distinction between Laravel and CodeIgniter?

Ans:

    Based onLaravelCodeIgniter
    Database model It is object-oriented. It’s relatively object-oriented.
    Built-in module It comes alongside an intrinsical module. It doesn’t associate with an intrinsical module.
    Structure Follows MVC structure of filing with a command-line tool referred to as trained worker. Follows the MVC structure however it provides easier boarding supported object-oriented programming.
    Development and Template It could be a smart possibility for front-end developers and it comes alongside the Blade guide engine. It’s easier to use and there’s no guide engine provided.

23.List numerous databases supported by the CodeIgniter framework?

Ans:

Following Databases square measure supported by the CodeIgniter framework:

  • MySQL (version five.1+) information that uses MySQL (deprecated), mysql, and PDO drivers.
  • Oracle information that uses oci8 and PDO drivers.
  • PostgreSQL information that uses Postgre and PDO drivers.
  • ODBC information that uses ODBC and PDO drivers.
  • SQLite information that uses SQLite version two, SQLite3 version three, alongside PDO drivers.
  • Interbase/Firebird information that uses iBase and PDO drivers.

24.Describe the work of the anchor tag in CodeIgniter?

Ans:

Anchor tag creates a customary hypertext mark-up language anchor link supporting the computer address of your native website.

  • Syntax: anchor($uri = ”, $title = ”, $attributes = ”)
  • The first parameter will have any segments you’d wish to append to the computer address. These segments may be a string or Associate in Nursing array.
  • The second parameter is the text that may be displayed with a link. The computer address is going to be employed in case you allow it to be blank.
  • The third parameter will contain the Associate in Nursing attribute list you’d like intercalary to the link. The attributes may be a string or Associate in Nursing associative array.

25.Explain CodeIgniter Email library?

Ans:

Features of Email category in CodeIgniter square measure given below:

  • Multiple protocols like Mail, Sendmail, and SMTP.
  • TLS and SSL cryptography for SMTP.
  • CC and BCCs.
  • Multiple recipients.
  • Attachments.
  • HTML or Plain-text email.
  • Priorities.
  • Word wrapping.
  • BCC Batch Mode, sanctio native larger email lists to be broken into smaller BCC batches.
  • Email Debugging tools.

26.How to send associate degree E-mail victimization CodeIgniter?

Ans:

Sending an associate degree email may be a straightforward method here. you’ll piece associate degree email on the fly or set your preferences within the app/Config/Email.php file. A basic example for demonstrating however you may send email is given below:

  • $email = \Config\Services::email();
  • $email->setFrom(‘your@interviewbit.com’, ‘Your Name’);
  • $email->setTo(‘someone@interviewbit.com’);
  • $email->setCC(‘another@another-example.com’);
  • $email->setBCC(‘them@their-example.com’);
  • $email->setSubject(‘Email Test’);
  • $email->setMessage(‘Testing the email category.’);
  • $email->send();

27.How to touch upon Error handling in CodeIgniter?

Ans:

CodeIgniter permits you to develop error coverage into your applications by victimizing the below-given functions. Also, it’s a category dedicated to error work that allows messages associated with error and debugging to be saved as text files.Functions associated with error handling are:

  • This performance can show the error message provided by the application/errors/errorgeneral.php example. show_error(‘message’ [, int $statuscode= five hundred ] )
  • This performance permits you to jot down messages onto your log files. you need to give anyone among 3 “levels” within the 1st parameter that indicates the message sort (debug, error, info), with the message itself within the second parameter. log_message(‘level’, ‘message’)

28.Explain the default URL pattern utilized in CodeIgniter?

Ans:

CodeIgniter can create use of a “segment-based” approach rather than a “query string-based” approach. CodeIgniter framework has four main components within the default URL pattern. First, we’ve the name of the server, and next, we’ve the name of the controller category followed by the name of the controller perform and performance parameters at the top. Codeigniter is accessed by victimizing the URL helper.

29.How you’ll add or load a model in CodeIgniter?

Ans:

In CodeIgniter, models are unit loaded furthermore as known as within your controller strategies. For loading a model, you need to use the below-given method: $this->load->model(‘name_of_the_model’); Include the relative path from the directory of your model, if your model is placed within a sub-directory. think about associate degree example, you have got a model that is placed at application / models/ blog/ All Posts.php you’ll load it by using: $this->load->model

30.Explain the CodeIgniter framework?

Ans:

The CodeIgniter application relies on the MVC (Model – read – Controller) model, that separates the applying logic from the presentation read. owing to presentation read separation from the PHP scripting, it permits your web content for script diminution.

31.Explain the way to forestall CodeIgniter from CSRF(Cross website Request Forgery)?

Ans:

There are some ways to shield CodeIgniter from CSRF, one technique of doing this can be to use a hidden field in each type on the web site. This hidden field is taken into account as a CSRF token, it’s a random value that changes with every hypertext transfer protocol request sent. when it gets inserted into the web site forms, it’ll be saved within the user’s session furthermore.

32.What is the safety parameter for XSS in CodeIgniter?

Ans:

Codeigniter has a Cross-Site Scripting(XSS) hack hindrance filter. This filter either mechanically runs, otherwise you will run its supported item, to filter all information associated with POST and COOKIE.The XSS filter can target the oft used strategies to trigger JavaScript code or different forms of code that arrange to hijack cookies or do the other malicious activity. If it identifies something suspicious or something disallowed is encountered, then it’ll convert the info to character entities.

33.What is the plugin in Codeigniter?

Ans:

Plugins work nearly identically to Helpers. Plugins ought to be saved to your system/plugins directory otherwise you will produce a folder known as plugins within your application folder and store them there. … CodeIgniter can look 1st in your system/application/plugins directory.

34.List all the auto-loadable resources on the market in CodeIgniter?

Ans:

The below-given things may be mechanically loaded in CodeIgniter:

  • Classes obtained within the directory named libraries.
  • Custom config files obtained within the directory named config.
  • Helper files obtained within the directory named helpers.
  • Models obtained within the directory named models.

35.What does one mean by the controller in CodeIgniter?

Ans:

The intermediary gift between the model and also the read for process the hypertext transfer protocol request and is employed for generating an online page is termed a controller. it’s thought of as the center of every hypertext transfer protocol request that exists on the net application of the user.

  • Consider the subsequent URL during this reference: projectName/index.php/welcome/

36.Why is there a necessity to piece the URL routes?

Ans:

Changing the URL routes has several advantages such as:

  • From the SEO(Search Engine Optimization) purpose of the read, to form URL SEO friendly and acquire a lot of user visits.
  • Hide some URL parts like controller name, perform name, etc. from the users for security functions.

37.What area unit the foremost distinguished options of CodeIgniter?

Ans:

A list of most distinguished options of CodeIgniter:

  • It is an associate degree open supply framework and liberal to use.
  • It is extraordinarily lightweight weighted.
  • It supports the Model read Controller (MVC) pattern.
  • It has full featured information categories and support for many platforms.
  • It is protrusile. you’ll simply extend the system by victimizing your libraries, helpers.

38.Explain MVC in CodeIgniter?

Ans:

CodeIgniter framework relies on MVC pattern. MVC may be a computer code that provides you a separate logical read from the presentation read. thanks to this, an online page contains the lowest scripting.

Model – The Controller manages models. It represents your organization. Model categories contain functions through which you’ll insert, retrieve or update info in your information.

View – read is the info that’s conferred before of users. It may be an online page or components of the page like header and footer.

39.Explain model in CodeIgniter?

Ans:

Model’s responsibility is to handle all information logic and illustration and cargo information within the views. it’s held in the application/models folder.Here, ModelName is the name of your model file. Remember, the category 1st letter should be in associate degree majuscule letter followed by different minuscule letters, and it ought to be identical as your file name.

40.How are you able to connect models to information manually?

Ans:

To connect information manually use following syntax, $this->load->database();

41.Explain views in CodeIgniter?

Ans:

  • they will be reused by embedding them anywhere in the controller file. They can’t decide directly, and they ought to be loaded within the controller’s file.
  • Create a file and put it aside in the application/views folder. for instance, we’ve got created a file Firstview.php.

42.How are you able to load a read in CodeIgniter?

Ans:

The read can’t be accessed directly. it’s continuously loaded within the controller file. Following operate is employed to load a read page: $this->load->view(‘page_name’);

  • Write your view’s page name within the bracket. You don’t have to specify .php unless you’re victimizing another extension.
  • Now, head to your controller file (Main.php)

43.Explain controller in CodeIgniter?

Ans:

A controller is the negotiator between models and views to method the protocol request and generates an internet page. it’s the middle of each request on your net application.Look at the top of the shot, the controller’s file name is Main.php (the initial letter must be in uppercase), and also the category name is Main (the initial letter must be in uppercase).

44.What is the default controller in CodeIgniter?

Ans:

The file laid out in the default controller loaded by default once no file name is mentioned within the computer address. By default, it’s welcome.php that is the initial page to be seen once putting in CodeIgniter.

45.How can you decide on a creator in CodeIgniter?

Ans:

To use a creator, you wish to say the subsequent line of code:

  • parent::_construct()

46.What is the default methodology name in CodeIgniter?

Ans:

By default the controller continuously calls index methodology. If you would like to decide a special methodology, then write it within the controller?s file and specify its name whereas vocation operates.

47.Explain the remapping methodology calls in CodeIgniter?

Ans:

The Second section of URI determines that methodology is being known as. If you would like to override it, you’ll use _remap() methodology. The _remap methodology continuously gets known even though URI is completely different. It overrides the URI.

48.What is a helper in CodeIgniter?

Ans:

Helpers at the cluster of functions that are accustomed assist the user to perform specific tasks.

49.How will a helper file be loaded?

Ans:

URL Helpers: accustomed to producing the links.

Text Helpers: used for text data format.

50.How are you able to load multiple helper files?

Ans:

To load multiple helper files, specify them in AN array:

  • $this->load->helper(
  • array(‘helper1’, ‘helper2’, ‘helper3’)
  • );

51.Explain the CodeIgniter library?

Ans:

CodeIgniter provides a fashionable set of libraries. it’s a necessary part of CodeIgniter because it will increase the developing speed of AN application. it’s placed within the system/library.

52.Where could a newly created library hold on in CodeIgniter structure?

Ans:

It ought to be placed in the application/libraries folder.

53.Can you extend native libraries in CodeIgniter?

Ans:

Yes, we will add some extended practicality to a native library by adding one or 2 ways. It replaces the whole library together with your version. therefore it’s better to increase the category. Extending and replacement is sort of identical with solely following exceptions.

54.How are you able to extend a category in CodeIgniter?

Ans:

You have to make a file name application/core/MY_Input.php and declare your category with category MY_Input extends CI_Input to extend the native input category in CodeIgniter.

55.What is routing in CodeIgniter?

Ans:

Routing could be a technique by which you’ll outline your URLs in line with the need rather than victimizing the predefined URLs. Routes may be classified in 2 ways, either victimization Wildcards or Regular Expressions.

56.What are CodeIgniter drivers?

Ans:

These are a specific sort of library that features a parent category and plenty of kid categories. These kid categories have access to the parent category, however to not their siblings. Drivers are found in the system/libraries folder.

57.How to initialize a driver in CodeIgniter?

Ans:

To initialize a driver, write the subsequent syntax:

  • $this->load->driver(‘class_name’);
  • Here, class_name is the driver name.

58.How to produce a driver in CodeIgniter?

Ans:

There are 3 steps to form a driver:

  • Making file structure.
  • Making driver list.
  • Making driver(s).

59.How to connect multiple databases in CodeIgniter?

Ans:

To connect over one information at the same time, do the subsequent:

  • $db1 = $this->load->database(‘group_one’, TRUE);
  • $db1 = $this->load->database(‘group_two’, TRUE);

60.How are you able to print SQL statements in CodeIgniter model?

Ans:

$this>db>insert_id();

61.What are CodeIgniter security methods?

Ans:

CodeIgniter security ways facilitate the formation of a secure application and method input file. The ways are given below:

  • XSS filtering
  • CSRF (Cross-site Request Forgery)
  • Class reference

62.How will CodeIgniter be prevented from CSRF?

Ans:

There are the assorted {ways|ways that|ways in that} by which, we will forestall CodeIgniter from CSRF. The foremost used methodology is victimization of the hidden field in every page of the web site. The hidden field is held within the user’s session. The field is modified with each protocol request. The user may be detected in each request to the web site. The hidden price is usually compared with the one saved within the session. If it’s similar, the request is valid.

63.What is the newest version of CodeIgniter?

Ans:

Although CodeIgniter three.1.11 is the current version that’s used aboard PHP five.6+, the team is developing CodeIgniter four, AN future version that may be used for net development in PHP seven.2.

64.How does one check the version of CodeIgniter you’re using?

Ans:

There are two ways to try to do this. the primary is to run the subsequent line of code:

  • The second means is to navigate to the system/core/CodeIgniter.php directory and run the subsequent code
  • define(‘CI_VERSION’, ‘2.1.4’)

65.How does one auto-load a model that’s to be used globally?

Ans:

This way, your model is loaded mechanically once the system is initialized.

66.Which databases are often employed in CodeIgniter?

Ans:

  • Database.
  • Drivers.
  • MySQL MySQL, MYSQLI, PDO.
  • PostgreSQL Postgre, PDO.
  • MS SQL MsSQL, Sqlsrv, PDO.
  • Oracle Oci8, PDO.
  • SQLite SQLite, sqlite3, PDO.
  • CUBRID Cubridand, PDO.
  • ODBC ODBC, PDO.
  • Interbase/Firebird iBase, PDO.

67.Where are all libraries set in CodeIgniter?

Ans:

All the pre-packaged libraries developed by CodeIgniter are obtainable within the system/libraries directory.

68.How does one load multiple libraries at an equivalent time?

Ans:

The process is comparable to loading multiple helper files. you utilize an equivalent line of code for loading one library however replace the parameter with AN array.

69.What are some naming conventions you ought to follow while making libraries?

Ans:

There are three conventions you ought to follow to create your own life easier:

  • Capitalize all file names, e.g. Sampleclass.php.
  • Capitalize all category declarations, e.g. category Sampleclass.
  • Choose an equivalent name for your files and categories.

70.What is the fundamental example of a category file?

Ans:

Here is that the basic example of a category file:

  • {
  • defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);
  • class Someclass perform some_method()
  • }

71.What is the tactic to increase a category in CodeIgniter?

Ans:

To extend a category, you have got to make a file named MY_Input.php within the application/core/ directory with the declaration:

  • Class MY_Input extends CI_Input .
  • Note that after once more, the name of the category and file has been unbroken consistently.

72.What is AN example of a computer address routing totally different from the default one?

Ans:

By default, CodeIgniter follows a typical structure for the computer address which supplies the primary phase to the category and therefore the second to the perform. this is often what it’s like:

  • something.com/class/function/id

However, you’ll prefer to have a special structure. Here is one example:

  • something.com/product/1.
  • something.com/product/2.
  • something.com/product/3.
  • In this example, the second phase is unbroken for a product ID rather than a way.

73.How does one specify your own routing rules?

Ans:

First, you have got to navigate to application/config/routes.php, and find the array referred to as $route. Next, you’ll use either a wildcard entry or a daily expression.

74.What are wildcards and regular expressions?

Ans:

You can have 2 styles of wildcards:

  • Matching solely numbers through: num-series.
  • Matching solely characters through: any-series.

75.What is the aim of configuring computer address routes?

Ans:

There are many reasons why you’d take together computer address routes:

  • It will increase the page visits to your website through higher programme visibility.
  • It will facilitate hiding the complicated expressions from your users.

76.What are hooks in CodeIgniter?

Ans:

Hooks are options that permit you to control the manner CodeIgniter usually executes its program, while not going into the relevant files and meddling with the code.

77.How does one alter hooks in CodeIgniter?

Ans:

Navigate to the application/config/config.php file and switch the subsequent setting to ‘TRUE’ as shown below:

  • $config[‘enable_hooks’] = TRUE;

78.How are you able to build use of a driver in CodeIgniter?

Ans:

You have to initialize it within the controller mistreatment the subsequent line of code:

  • $this -> load -> driver(‘class_name’);

79.How are you able to produce a driver in CodeIgniter?

Ans:

You have to require care of three things if you would like to create a driver:

  • Create a file name like ‘Driver_name.php’
  • Create a listing of drivers within this file
  • Write the code for every individual driver

80.What is the tactic to link multiple databases in CodeIgniter?

Ans:

Here is however you may connect multiple databases at an equivalent time (simultaneously).

81.What are security ways in CodeIgniter?

Ans:

CodeIgniter has many ways of implementing security in your application and protecting the raw computer file fed to your program. Here are three methods:

  • CSRF (Cross-site Request Forgery).
  • Class reference.
  • XSS filtering.

82.How to do one Link pictures From a read in Codeigniter?

Ans:

To link pictures from a read {in a|during a|in AN exceedingly|in a very} codeigniter 1st use an absolute path to the resources needed and link the image from a read in codeigniter /css/styles.css /js/query.php /img/news/566.gpg.

83.How are you able to Extend the category in Codeigniter?

Ans:

To extend a native input category the user should 1st build a file that is to be named application/core/MY_Input.php then proceed to declare the category with category MY_Input extends CI_Input .

84.Have you ever detected csrf attacks?

Ans:

Yes, Cross-Site Request Forgery (CSRF) is AN attack that forces AN user to execute unwanted actions on an internet application during which they’re presently genuine .

85.Do you assume a csrf token ought to solely be generated when authentication ?

Ans:

No, they must be created before authentication too:

  • https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#login-csrf.

86.Difference between XSS and CSRF ?

Ans:

87.How are you able to take away index.php from the universal resource locator in Codeigniter?

Ans:

Follow below steps to index.php from universal resource locator in Codeigniter:

Step 1: Open config.php and replaces:

  • $config[‘index_page’] = “index.php” to $config[‘index_page’] = “”
  • and
  • $config[‘uri_protocol’] =”AUTO” to $config[‘uri_protocol’] = “REQUEST_URI”

Step 2: modification your .htaccess file to:

  • RewriteEngine on
  • RewriteCond $1 !
  • RewriteRule ^(.*)$ /index.php/$1 [L]

88.What are Sessions In CodeIgniter?

Ans:

CodeIgniter Session category permits you to maintain a user’s “state” and track their activity whereas they’re browsing your web site.In order to use session, you wish to load Session category in your controller.

89.How to scan a session in CodeIgniter?

Ans:

Use $this->session->userdata(); technique of session category to scan session information in CodeIgniter:

  • $this->session->userdata(‘your_key’); you’ll additionally scan session information by victimizing the magic getter of CodeIgniter Session category.

90.How to write a session in CodeIgniter?

Ans:

Session’s category set_userdata() technique is employed to form a session in CodeIgniter. This technique takes an Associate in Nursing associative array containing your information that you just wish to feature in session.

91.How to take away a session in CodeIgniter?

Ans:

Session’s category unset_userdata() technique is employed to get rid of session information in CodeIgniter.

92.How to get the last inserted id in CodeIgniter?

Ans:

CodeIgniter dB category insert_id() technique is employed to urge the last insert id.

93.What is the CLI?

Ans:

CLI could be a text-based command-line interface for interacting with computers via a group of commands.

94.Why do we have a tendency to use the command line interface in Codeigniter?

Ans:

In Codeigniter, we are able to use command line interface for:

  • Run your cron jobs with no need to use wget or curl.
  • Make your cron-jobs inaccessible from being loaded within the universal resource locator by checking the come worth of is_cli().
  • Make interactive “tasks” which will do things like set permissions, prune cache folders, run backups, etc.
  • Helps to integrate Codeigniter with alternative applications in alternative languages. For instance, a random C++ script may decide one command and run code in your models!

95.How to do 301 redirects in CodeIgniter?

Ans:

We can use a direct helper to try to do 301 redirects in Codeigniter.

Syntax :

  • redirect(‘/posts/13’, ‘New location’, 301)

96.How to check if a field or column exists in an exceedingly table or not in Codeigniter?

Ans:

Code for Checking a field or column exists or not in an exceedingly Codeigniter table.

97.What is_cli() technique in Codeigniter?

Ans:

In Codeigniter is_cli() technique is employed to ascertain whether a request is from the program line or not.Returns TRUE if the appliance is run through the program line and FALSE if not.

98. A way to set or get config variables in Codeigniter?

Ans:

Set Config Value: $this->config->set_item(‘mainURL’,’itsolutionstuff.com’);

Get Config Value: $mainURL = $this->config->item(‘mainURL’);

Example Config Value: scan Also Codeigniter three Datatables Ajax Example From Scratch.

99.How to delete a record in Codeigniter?

Ans:

In Codeigniter, delete perform is employed to delete the one or additional row information from a table:

  • //DELETE FROM table wherever id = $id
  • $conditions =[‘id’ => $id]
  • $this->db->delete(‘table_name’, $conditions);
  • // Deleting records from quite one tables in one go
  • $id=1;
  • $tables = array(‘table1’, ‘table2’, ‘table3’);
  • $this->db->where(‘id’, $id);
  • $this->db->delete($tables);

100.How to implement validations in Codeigniter?

Ans:

You can implement type validations in Codeigniter employing a form_validation library.

Are you looking training with Right Jobs?

Contact Us

Popular Courses