← 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?
- $result === false
- !$result
- $result == false
- 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?
- isset($data["nickname"])
- empty($data["nickname"])
- $data["nickname"] ?? false
- 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?
- empty($data["value"]) ? "default" : $data["value"]
- $data["value"] == false ? "default" : $data["value"]
- $data["value"] ?? "default"
- $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