Create New Post

CodeIgniter MCQs with answer part - 3

  1. Which method is used to redirect users to a different URL in CodeIgniter?

    • A) redirect()
    • B) forward()
    • C) navigate()
    • D) move()

    Answer: A) redirect()

  2. What is the purpose of the routes.php file in a CodeIgniter project?

    • A) To define custom routes for URLs
    • B) To configure database connections
    • C) To specify controller methods for handling requests
    • D) To set up environment-specific configurations

    Answer: A) To define custom routes for URLs

  3. Which CodeIgniter library is used for file uploading?

    • A) File_Loader
    • B) Upload_Library
    • C) File_Uploading
    • D) File_Upload

    Answer: D) File_Upload

  4. What is the purpose of the validation_errors() function in CodeIgniter?

    • A) To display validation errors in a view
    • B) To retrieve validation rules from the database
    • C) To log validation errors in a file
    • D) To set custom validation error messages

    Answer: A) To display validation errors in a view

  5. Which method is used to set cookies in CodeIgniter?

    • A) $this->cookie->set()
    • B) $this->set_cookie()
    • C) $this->input->set_cookie()
    • D) $this->input->cookie()

    Answer: C) $this->input->set_cookie()

  6. What is the purpose of the csrf_protection setting in the CodeIgniter configuration?

    • A) To enable cross-site request forgery (CSRF) protection
    • B) To configure the session driver for CSRF protection
    • C) To define custom CSRF tokens
    • D) CSRF protection is enabled by default in CodeIgniter

    Answer: A) To enable cross-site request forgery (CSRF) protection

  7. Which of the following methods is used to encrypt data in CodeIgniter?

    • A) encrypt()
    • B) encrypt_data()
    • C) encrypt_string()
    • D) encode()

    Answer: C) encrypt_string()

  8. How do you enable query caching in CodeIgniter?

    • A) By setting the cache_query configuration option to TRUE
    • B) By calling the cache_query() method in the controller
    • C) By configuring the database driver to enable caching
    • D) Query caching is enabled by default in CodeIgniter

    Answer: C) By configuring the database driver to enable caching

  9. Which CodeIgniter feature allows you to execute custom code at specific points during the request lifecycle?

    • A) Hooks
    • B) Middleware
    • C) Interceptors
    • D) Filters

    Answer: A) Hooks

  10. How do you enable logging in CodeIgniter?

    • A) By setting the log_enabled configuration option to TRUE
    • B) By calling the enable_log() method in the controller
    • C) By configuring the logging threshold in the config.php file
    • D) Logging is enabled by default in CodeIgniter

    Answer: C) By configuring the logging threshold in the config.php file

Comments

Leave a Reply

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

17706