Modern PHP 8 interview questions

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.

Take the free IT readiness check

or take a mock interview set up for this area

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

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
  1. A.Match expression
  2. B.Nullsafe operator
  3. C.Constructor property promotion
  4. D.Enumeration

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.Match expression
  2. B.Enumeration
  3. C.Nullsafe operator
  4. D.Attribute

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.Constructor property promotion
  2. B.Attribute
  3. C.Enumeration
  4. D.Fiber

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.Attribute
  2. B.Enumeration
  3. C.Fiber
  4. D.Nullsafe operator

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.Enumeration
  2. B.Attribute
  3. C.Constructor property promotion
  4. D.Nullsafe operator

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

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
  1. A.Attribute
  2. B.Constructor property promotion
  3. C.Fiber
  4. D.Match expression

Answer + AI explanation with Pro

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

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.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers