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
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
2. Which term means: "a shorthand that declares and assigns object properties directly by adding a visibility modifier to constructor parameters, removing boilerplate assignments"?
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
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
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"?
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
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
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"?
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
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
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"?
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
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
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"?
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
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
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"?
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
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.