Modern PHP 8 interview questions

18 real Modern PHP 8 questions from the PHP bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What is Constructor property promotion?

Mid
  1. A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

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
  1. A.Match expression
  2. B.Nullsafe operator
  3. C.Constructor property promotion
  4. D.Enumeration
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Mid
  1. A.Constructor property promotion — a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

4. What is Match expression?

Mid
  1. 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
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

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
  1. A.Match expression
  2. B.Enumeration
  3. C.Nullsafe operator
  4. D.Attribute
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Mid
  1. 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
  2. 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
  3. C.Match expression — a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  4. 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
Reveal the answer + AI explanation — free account

7. What is Enumeration?

Mid
  1. A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

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
  1. A.Constructor property promotion
  2. B.Attribute
  3. C.Enumeration
  4. D.Fiber
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Mid
  1. 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
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

10. What is Nullsafe operator?

Mid
  1. A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

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
  1. A.Attribute
  2. B.Enumeration
  3. C.Fiber
  4. D.Nullsafe operator
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Mid
  1. 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
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

13. What is Attribute?

Senior
  1. A.a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

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
  1. A.Enumeration
  2. B.Attribute
  3. C.Constructor property promotion
  4. D.Nullsafe operator
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Senior
  1. A.Attribute — a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

16. What is Fiber?

Senior
  1. 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
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

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
  1. A.Attribute
  2. B.Constructor property promotion
  3. C.Fiber
  4. D.Match expression
Reveal the answer + AI explanation — free account

18. Which statement is correct?

Senior
  1. 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
  2. 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
  3. 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
  4. 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
Reveal the answer + AI explanation — free account

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Modern PHP 8 free