Create New Post

CodeIgniter MCQs with answer part - 1

  1. What is CodeIgniter?

    • A) A content management system (CMS)
    • B) A PHP framework
    • C) A JavaScript library
    • D) An operating system

    Answer: B) A PHP framework

  2. Which architectural pattern does CodeIgniter follow?

    • A) MVP (Model-View-Presenter)
    • B) MVVM (Model-View-ViewModel)
    • C) MVC (Model-View-Controller)
    • D) MVPVM (Model-View-Presenter-ViewModel)

    Answer: C) MVC (Model-View-Controller)

  3. What is the purpose of a controller in CodeIgniter?

    • A) To handle database interactions
    • B) To manage user authentication
    • C) To handle HTTP requests and route them to appropriate methods
    • D) To display the user interface

    Answer: C) To handle HTTP requests and route them to appropriate methods

  4. Which directory contains the main configuration files in a CodeIgniter project?

    • A) application
    • B) system
    • C) public
    • D) config

    Answer: D) config

  5. What is the purpose of the autoload.php file in CodeIgniter?

    • A) To load core system files
    • B) To autoload helper functions, libraries, and models
    • C) To configure database settings
    • D) To define custom routes

    Answer: B) To autoload helper functions, libraries, and models

  6. Which of the following methods is used to load a view file in a controller?

    • A) $this->load->view()
    • B) $this->render->view()
    • C) $this->render_view()
    • D) $this->load->template()

    Answer: A) $this->load->view()

  7. How can you pass data from a controller to a view in CodeIgniter?

    • A) By setting global variables in the controller
    • B) By using sessions
    • C) By passing an array to the load->view() method
    • D) By directly accessing the model from the view

    Answer: C) By passing an array to the load->view() method

  8. Which method is used to perform database queries using CodeIgniter's Query Builder?

    • A) $this->db->query()
    • B) $this->db->get()
    • C) $this->db->execute()
    • D) $this->db->select()

    Answer: B) $this->db->get()

  9. How can you enable CSRF protection in CodeIgniter?

    • A) By setting the csrf_protection configuration option to TRUE
    • B) By using a middleware library
    • C) By adding a hidden field with a CSRF token to each form
    • D) CSRF protection is enabled by default in CodeIgniter

    Answer: A) By setting the csrf_protection configuration option to TRUE

  10. Which of the following is NOT a valid CodeIgniter URL pattern?

    • A)  http://example.com/index.php/controller/method/parameter
    • B)  http://example.com/controller/method/parameter
    • C)  http://example.com/index.php/controller/parameter
    • D)  http://example.com/index.php/method/parameter

    Answer: D) http://example.com/index.php/method/parameter

Comments

Leave a Reply

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

71327