Programming MCQs Feed

📊 PHP
Q. Which HTTP method is used to partially update a resource?
  • (A) POST
  • (B) PUT
  • (C) PATCH
  • (D) DELETE
💬 Discuss
✅ Correct Answer: (C) PATCH

Explanation: PATCH updates part of a resource.

📊 PHP
Q. Which PHP function sets HTTP response status code?
  • (A) http_status()
  • (B) status_code()
  • (C) http_response_code()
  • (D) set_status()
💬 Discuss
✅ Correct Answer: (C) http_response_code()

Explanation: http_response_code() sets or gets the HTTP status.

📊 PHP
Q. Which PHP function sends a raw HTTP header?
  • (A) send_header()
  • (B) header()
  • (C) http_header()
  • (D) set_header()
💬 Discuss
✅ Correct Answer: (B) header()

Explanation: header() sends HTTP headers.

📊 PHP
Q. Which PHP function reads raw JSON input from request body?
  • (A) $_POST
  • (B) file_get_contents('php://input')
  • (C) $_REQUEST
  • (D) json_input()
💬 Discuss
✅ Correct Answer: (B) file_get_contents('php://input')

Explanation: Used to read raw request body.

📊 PHP
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
💬 Discuss
✅ Correct Answer: (D) Both 1 and 3

Explanation: Header + json_encode ensures proper JSON response.

📊 PHP
Q. Which PHP OPcache feature improves performance?
  • (A) Caching PHP output
  • (B) Caching compiled bytecode
  • (C) Caching database queries
  • (D) Caching sessions
💬 Discuss
✅ Correct Answer: (B) Caching compiled bytecode

Explanation: OPcache stores precompiled PHP bytecode.

📊 PHP
Q. Which php.ini directive enables OPcache?
  • (A) opcache.enable
  • (B) opcache.start
  • (C) opcache.on
  • (D) opcache.cache
💬 Discuss
✅ Correct Answer: (A) opcache.enable

Explanation: opcache.enable turns OPcache on.

📊 PHP
Q. Which PHP function measures script execution time in microseconds?
  • (A) time()
  • (B) microtime()
  • (C) execution_time()
  • (D) script_time()
💬 Discuss
✅ Correct Answer: (B) microtime()

Explanation: microtime() returns current Unix timestamp with microseconds.

📊 PHP
Q. Which PHP feature enforces strict type checking?
  • (A) declare(strict_types=1)
  • (B) type_check()
  • (C) strict_mode()
  • (D) php_strict()
💬 Discuss
✅ Correct Answer: (A) declare(strict_types=1)

Explanation: Enables strict type checking.

📊 PHP
Q. Which PHP interface must be implemented to use foreach with objects?
  • (A) Iterator
  • (B) Iterable
  • (C) Traversable
  • (D) ArrayAccess
💬 Discuss
✅ Correct Answer: (C) Traversable

Explanation: Traversable allows object iteration.