PHP MCQs with answers Page - 122

Here, you will find a collection of MCQ questions on PHP. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 832.27K Points
Coach

Q. Which PHP function outputs JSON with correct headers?

  • (A) echo json_encode()
  • (B) print json_encode()
  • (C) header('Content-Type: application/json')
  • (D) Both 1 and 3

A

Admin • 832.27K Points
Coach

Q. Which PHP OPcache feature improves performance?

  • (A) Caching PHP output
  • (B) Caching compiled bytecode
  • (C) Caching database queries
  • (D) Caching sessions

A

Admin • 832.27K Points
Coach

Q. Which php.ini directive enables OPcache?

  • (A) opcache.enable
  • (B) opcache.start
  • (C) opcache.on
  • (D) opcache.cache

A

Admin • 832.27K Points
Coach

Q. Which PHP function measures script execution time in microseconds?

  • (A) time()
  • (B) microtime()
  • (C) execution_time()
  • (D) script_time()

A

Admin • 832.27K Points
Coach

Q. Which PHP feature enforces strict type checking?

  • (A) declare(strict_types=1)
  • (B) type_check()
  • (C) strict_mode()
  • (D) php_strict()

A

Admin • 832.27K Points
Coach

Q. Which PHP keyword is used to handle exceptions?

  • (A) throw
  • (B) catch
  • (C) try
  • (D) All of the above

A

Admin • 832.27K Points
Coach

Q. Which PHP interface must be implemented to use foreach with objects?

  • (A) Iterator
  • (B) Iterable
  • (C) Traversable
  • (D) ArrayAccess

A

Admin • 832.27K Points
Coach

Q. Which PHP interface allows objects to be accessed like arrays?

  • (A) Iterator
  • (B) Traversable
  • (C) ArrayAccess
  • (D) Countable

A

Admin • 832.27K Points
Coach

Q. Which PHP interface allows count() to work on objects?

  • (A) Countable
  • (B) Iterable
  • (C) Iterator
  • (D) ArrayAccess

A

Admin • 832.27K Points
Coach

Q. Which PHP extension is recommended for secure database access?

  • (A) mysql
  • (B) mysqli
  • (C) PDO
  • (D) odbc

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ