CodeIgniter is an open-source software rapid development web framework. CodeIgniter is used to build dynamic web pages with PHP.
CodeIgniter MCQs: This section contains multiple-choice questions and answers on the various topics of CodeIgniter. Practice these MCQs to test and enhance your skills on CodeIgniter.
List of CodeIgniter MCQs
1. CodeIgniter is a ____.
- Enterprise architecture framework
- Database Framework
- Testing framework
- Application development framework
Answer: D) Application development framework
Explanation:
CodeIgniter is an application development framework.
2. CodeIgniter uses which programming language?
- PHP
- JavaScript
- Java
- Python
Answer: A) PHP
Explanation:
CodeIgniter is a tool kit that uses PHP language.
3. CodeIgniter is licensed under which of the following?
- Apache
- MIT
- Microsoft
Answer: B) MIT
Explanation:
CodeIgniter is licensed under the MIT license.
4. CodeIgniter uses which of the following approach?
- MVC
- Master-slave
- Client-server
- Layered
Answer: A) MVC
Explanation:
CodeIgniter uses the Model-View-Controller approach.
5. Your data structures are represented by the ____.
- View
- Controller
- Model
Answer: C) Model
Explanation:
Your data structures are represented by the Model.
6. The ____ acts as a bridge between the Model and the View.
- Processor
- Controller
- Director
- Repository
Answer: B) Controller
Explanation:
The Controller acts as a bridge between the Model and the View.
7. The View is the information that is displayed to the user.
- View
- Controller
- Model
Answer: A) View
Explanation:
The View is the information that is displayed to the user.
8. The class name must start with ____ letter.
- Lowercase
- Uppercase
- Any case
Answer: B) Uppercase
Explanation:
The class name must start with an uppercase letter.
9. Views can be called directly?
- True
- False
Answer: B) False
Explanation:
Views might be basic or complicated web pages that can be called by the controller. The webpage may have a header, footer, sidebar, and so on. The view cannot be called directly.
10. Which kind of relationship is there between a URL string and its corresponding controller class/method?
- Many-to-one
- One-to-many
- Many-to-many
- One-to-one
Answer: D) One-to-one
Explanation:
A URL string and its related controller class/method usually have a one-to-one relationship.
11. How many reserved routes are there in CodeIgniter?
- 4
- 3
- 5
- 7
Answer: B) 3
Explanation:
With CodeIgniter, there are three reserved routes:
- $route[‘default_controller’]
- $route[‘404_override’]
- $route[‘translate_uri_dashes’]
12. If the URI includes no data, ____ route indicates which controller class should be loaded.
- $route[‘default_controller’]
- $route[‘404_override’]
- $route[‘translate_uri_dashes’]
Answer: A) $route[‘default_controller’]
Explanation:
If the URI includes no data, $route[‘default_controller’] route indicates which controller class should be loaded.
13. If the specified controller cannot be found, ____ route specifies which controller class should be loaded.
- $route[‘default_controller’]
- $route[‘404_override’]
- $route[‘translate_uri_dashes’]
Answer: B) $route[‘404_override’]
Explanation:
If the specified controller cannot be found, $route[‘404_override’] route specifies which controller class should be loaded.
14. Which of the following can be used to customize routes?
- Wildcards
- Regular expressions
- Both
- None
Answer: C) Both
Explanation:
Wildcards and regular expressions can be used to customize routes.
15. CodeIgniter reads its routing rules from ____?
- Top-to-Bottom
- Bottom-to-top
- Both
- None
Answer: A) Top-to-Bottom
Explanation:
CodeIgniter reads its routing rules from top to bottom.
16. In the URL given below what does the first segment indicates?
includehelp.com/class/function/id/
- The first section denotes the controller class to be called.
- The first section denotes the class function or method to be invoked.
- The first section represents the ID as well as any variables supplied to the controller.
Answer: A) The first section denotes the controller class to be called.
Explanation:
The first section of the URL denotes the controller class to be called.
17. In the URL given below what does the second segment indicates?
includehelp.com/class/function/id/
- The second section denotes the controller class to be called.
- The second section denotes the class function or method to be invoked.
- The second section represents the ID as well as any variables supplied to the controller.
Answer: B) The second section denotes the class function or method to be invoked.
Explanation:
The second section denotes the class function or method to be invoked.
18. In how many ways you can connect to the database?
- 5
- 4
- 2
- 3
Answer: C) 2
Explanation:
We can connect to the database in the following two ways –
- Automatic connecting
- Manual connecting
19. Which of the following method is used to put a record into the database?
- Add()
- Put()
- Create()
- Insert()
Answer: D) Insert()
Explanation:
The insert() method is used to put a record into the database.
20. Prefixing method names with an ____ will prevent them from being called.
- Double underscore
- Underscore
- @ at
Answer: B) Underscore
Explanation:
Prefixing method names with an underscore will prevent them from being called.
21. The data to be updated will be set using the ____ method.
- Update()
- Changed()
- Setup()
- Set()
Answer: D) Set()
Explanation:
The data to be updated will be set using the set() method.
22. The ____ method is used to delete a record from the database.
- Erase()
- Del
- Delete()
- Remove()
Answer: C) Delete()
Explanation:
The delete() method is used to delete a record from the database.
23. The ____ method is used to select a record from the database.
- Get()
- Hold()
- Retrieve()
Answer: A) Get()
Explanation:
The get method is used to select a record from the database.
24. Helpers are written in an Object-Oriented format.
- True
- False
Answer: B) False
Explanation:
Helpers are not written in an Object-Oriented way. These are basic procedural functions.
25. CodeIgniter does load Helper Files by default?
- True
- False
Answer: B) False
Explanation:
Helper Files are not loaded by default in CodeIgniter. Therefore the first step in utilizing a Helper is to load it. After loaded, it is available in your controller and views globally.
26. How many wildcard types you can use in CodeIgniter?
- 5
- 4
- 3
- 2
Answer: D) 2
Explanation:
You can use two wildcard types:
- (:any)
- (:num)
27. Wildcards are aliases for regular expressions?
- True
- False
Answer: A) True
Explanation:
Wildcards are aliases for regular expressions.
28. An ____ in CodeIgniter is an error handler class.
- Blocker
- Inhibitor
- Receptor
Answer: B) Inhibitor
Explanation:
An inhibitor in CodeIgniter is an error handler class.
29. A ____ is a sort of library that contains a parent class and numerous child classes.
- Router
- Engine
- Driver
Answer: C) Driver
Explanation:
A driver is a sort of library that contains a parent class and numerous child classes.
30. How many types of helper files are there?
- 5
- 4
- 2
- 3
Answer: D) 3
Explanation:
There are three types of helper files:
- URL helpers
- Text helpers
- Cookies helpers
31. In the following tag; $this->output->cache($n)
What does $n represent?
- $n is the amount of time you want the page to be cached between refreshes.
- $n is the number of pages you want to cache.
Answer: A) $n is the amount of time you want the page to be cached between refreshes.
Explanation:
$n is the amount of time you want the page to be cached between refreshes.
32. CSRF stands for ____?
- Cross-section request form
- Cross-site request form
- Cross-site request forgery
- Cross section request forgery
Answer: C) Cross-site request forgery
Explanation:
CSRF stands for Cross-site request forgery.
33. If you need to erase the cache manually, use the ____ method.
- Remove_cache()
- Del_Cache()
- Delete cache()
Answer: C) Delete cache()
Explanation:
If you need to erase the cache manually, use the delete_cache() method.
34. The ____ Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages.
- Sensor
- Profiler
- Analyzer
Answer: B) Profiler
Explanation:
The Profiler Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages.
35. CodeIgniter’s ____ class makes it simple to support several languages for internationalization?
- Language
- Speech
- Dialect
Answer: A) Language
Explanation:
CodeIgniter’s language class makes it simple to support several languages for internationalization.
36. Cookie handling is handled by a helper named “____” in CodeIgniter.
- Cookie
- Cookie helper
- Data helper
- Cookie and session
Answer: B) Cookie helper
Explanation:
Cookie handling is handled by a helper named “Cookie Helper” in CodeIgniter.
37. Which of the following function is used to erase the cookie?
- Remove_cookie()
- Erase_cookie()
- Del_cookie()
- Delete_cookie()
Answer: D) Delete_cookie()
Explanation:
To erase the cookie, use the delete_cookie() method.
38. The cookie is obtained using the ____ method.
- get_cookie()
- retrieve_cookie()
- obtain()
Answer: A) get_cookie()
Explanation:
The cookie is obtained using the get_cookie() method.
39. In CodeIgniter, among library and helper which of them follows an object-oriented approach?
- Helper
- Library
Answer: B) Library
Explanation:
Among library and helper, the library follows an object-oriented approach.
40. Which of the following folder will contain the base class of your application?
- Hooks
- Helpers
- Config
- Core
Answer: D) Core
Explanation:
The core folder will contain the base class of your application.
41. CodeIgniter processes all transactions in ____ Mode by default.
- Test
- Strict
- Hard
Answer: B) Strict
Explanation:
CodeIgniter processes all transactions in Strict Mode by default.
42. Which of the following should be used while running manual transactions?
- $this->db->trans_begin()
- $this->db->trans_start().
Answer: A) $this->db->trans_begin()
Explanation:
You should use $this->db->trans_begin() when running manual transactions, NOT $this->db->trans_start().
43. Which of the following returns an array with the names of all the tables in the database to which you are presently connected?
- $this->db->tables();
- $this->db->list_tables();
- $this->db->array_tables();
Answer: B) $this->db->list_tables();
Explanation:
$this->db->list_tables(); returns an array with the names of all the tables in the database to which you are presently connected.
44. Which of the following returns an array of objects containing field information?
- $this->db->data()
- $this->db->table_data()
- $this->db->field_data()OOP
Answer: C) $this->db->field_data()OOP
Explanation:
$this->db->field_data()OOP, returns an array of objects containing field information.
45. Which class allows you to cache queries as text files to minimize database load?
- Database Caching Class
- Caching Class
- Database record Caching Class
Answer: A) Database Caching Class
Explanation:
The Database Caching Class allows you to cache queries as text files to minimize database load.
46. Which of the following removes cache files connected with a certain page?
- $this->db->cache_remove()
- $this->db->cache_erase()
- $this->db->cache_del()
- $this->db->cache_delete()
Answer: D) $this->db->cache_delete()
Explanation:
$this->db->cache_delete() removes cache files connected with a certain page.
47. Which of the following clears all existing cache files?
- $this->db->cache_remove_all()
- $this->db->cache_delete_all()
- $this->db->cache_erase_all()
Answer: B) $this->db->cache_delete_all()
Explanation:
$this->db->cache_delete_all(), clears all existing cache files.
48. Is CodeIgniter open-source?
- Yes
- No
Answer: A) Yes
Explanation:
CodeIgniter is an open-source web framework for quick software development.
49. How many different sorts of messages can CodeIgniter log?
- 2
- 3
- 4
- 5
Answer: B) 3
Explanation:
Three message types are logged in CodeIgniter:
- Error Messages
- Debug Messages
- Informational Messages
50. Which of the following permits you to create the database?
- $this->dbforge->create(‘db_name’)
- $this->dbforge->create_newdatabase(‘db_name’)
- $this->dbforge->create_database(‘db_name’)
Answer: C) $this->dbforge->create_database(‘db_name’)
Explanation:
$this->dbforge->create_database(‘db_name’), Permits you to create the database.