18 Modern PHP 8 questions from the PHP bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.
Free to start: the 2-minute IT readiness check — six questions and a result.
A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
B.a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
C.a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
D.a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
Answer + AI explanation with Pro
2. Which term means: "a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments"?
Mid
A.Match expression
B.Nullsafe operator
C.Constructor property promotion
D.Enumeration
Answer + AI explanation with Pro
3. Which statement is correct?
Mid
A.Constructor property promotion — a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
B.Constructor property promotion — a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
C.Constructor property promotion — a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
D.Constructor property promotion — a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
Answer + AI explanation with Pro
4. What is Match expression?
Mid
A.a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
B.a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
C.a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
D.a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
Answer + AI explanation with Pro
5. Which term means: "a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error"?
Mid
A.Match expression
B.Enumeration
C.Nullsafe operator
D.Attribute
Answer + AI explanation with Pro
6. Which statement is correct?
Mid
A.Match expression — a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
B.Match expression — structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations
C.Match expression — a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
D.Match expression — a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
Answer + AI explanation with Pro
7. What is Enumeration?
Mid
A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
B.a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
C.a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
D.a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
Answer + AI explanation with Pro
8. Which term means: "a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar"?
Mid
A.Constructor property promotion
B.Attribute
C.Enumeration
D.Fiber
Answer + AI explanation with Pro
9. Which statement is correct?
Mid
A.Enumeration — a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
B.Enumeration — structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations
C.Enumeration — a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
D.Enumeration — a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
Answer + AI explanation with Pro
10. What is Nullsafe operator?
Mid
A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
B.a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
C.a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
D.a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
Answer + AI explanation with Pro
11. Which term means: "a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error"?
Mid
A.Attribute
B.Enumeration
C.Fiber
D.Nullsafe operator
Answer + AI explanation with Pro
12. Which statement is correct?
Mid
A.Nullsafe operator — a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
B.Nullsafe operator — a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
C.Nullsafe operator — a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
D.Nullsafe operator — a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
Answer + AI explanation with Pro
13. What is Attribute?
Senior
A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
B.a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
C.structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations
D.a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
Answer + AI explanation with Pro
14. Which term means: "structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations"?
Senior
A.Enumeration
B.Attribute
C.Constructor property promotion
D.Nullsafe operator
Answer + AI explanation with Pro
15. Which statement is correct?
Senior
A.Attribute — a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
B.Attribute — a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
C.Attribute — structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations
D.Attribute — a PHP 8.1 type declaring a fixed set of named cases as its only valid instances, optionally backed by a string or integer scalar
Answer + AI explanation with Pro
16. What is Fiber?
Senior
A.a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
B.structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations
C.a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
D.a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
Answer + AI explanation with Pro
17. Which term means: "a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency"?
Senior
A.Attribute
B.Constructor property promotion
C.Fiber
D.Match expression
Answer + AI explanation with Pro
18. Which statement is correct?
Senior
A.Fiber — a PHP 8.1 primitive providing a full-stack interruptible function that can suspend its own execution and be resumed later, used to build cooperative concurrency
B.Fiber — structured, machine-readable metadata attached to declarations using a number-sign and square brackets, readable at runtime via reflection to replace doc-comment annotations
C.Fiber — a question-mark arrow that short-circuits a method or property access chain to null when the left operand is null instead of raising an error
D.Fiber — a PHP 8 control structure that returns a value by comparing a subject against arms using strict identity, with no fall-through and a required exhaustive default or thrown error
Answer + AI explanation with Pro
Free to start
Start with a free readiness check
Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Modern PHP 8 question come with Pro.