PHP

← All exam tracks

Modern PHP 8 · Runtime & Tooling

PHP

Practice original scenario-based PHP questions. Take a timed mock, focus on a topic, and learn from detailed explanations. These are independent practice materials, not official exam questions or a guarantee of certification readiness.

16 questions · 24 minutes · 70% practice target

Create an account to practice Already a member? Sign in

Topics you will practice

  • Types & Values
  • Functions & Runtime
  • Data & Security
  • Tooling & Testing

Try a sample

Think through each question, then reveal the explanation. Full attempts save your answers and scores to your account.

A function may return integer 0 as a valid result or false on failure. Which check distinguishes failure?

  1. $result === false
  2. !$result
  3. $result == false
  4. empty($result)
Show answer and explanation

Correct answer: $result === false

Strict comparison distinguishes boolean false from integer zero. Truthiness, loose equality, and empty can treat a valid zero as failure.

An array contains ["nickname" => null]. You must distinguish that present key from a missing key. Which check fits?

  1. isset($data["nickname"])
  2. empty($data["nickname"])
  3. $data["nickname"] ?? false
  4. array_key_exists("nickname", $data)
Show answer and explanation

Correct answer: array_key_exists("nickname", $data)

array_key_exists checks presence even when the value is null. isset treats null as unset, while empty and null coalescing do not preserve this distinction.

An optional array value may be missing or null. You want a default in those two cases but must preserve 0 and an empty string. Which expression fits?

  1. empty($data["value"]) ? "default" : $data["value"]
  2. $data["value"] == false ? "default" : $data["value"]
  3. $data["value"] ?? "default"
  4. $data["value"] ?: "default"
Show answer and explanation

Correct answer: $data["value"] ?? "default"

The null-coalescing operator falls back for missing/null values. Truthy fallbacks also replace valid falsy values such as zero and an empty string.

Study references