PHP 8 interview question · Most asked

What are the most important features introduced in PHP 8.0?

Summary

PHP 8.0 added the JIT compiler, union types, named arguments, attributes, constructor property promotion, the match expression, the nullsafe operator and much stricter, more consistent error handling.

Longer Answer

PHP 8.0 (November 2020) was a major release focused on type safety and expressiveness. The language gained union types (int|string), the mixed and static return types, named arguments, attributes (native metadata replacing docblock annotations), constructor property promotion, the match expression, and the nullsafe operator (?->).

Under the hood it shipped the JIT (tracing and function modes on top of OPcache), turned many warnings into TypeError/ValueError exceptions for internal functions, and changed string-to-number comparison semantics so 0 == "foo" is now false.

Key Points

  • Union types, mixed, static return type
  • Named arguments and constructor promotion reduce boilerplate
  • Attributes give first-class, reflectable metadata
  • match is a strict, expression-based switch
  • Saner string/number comparisons and consistent internal-function errors

Explanation

What interviewers look for

A grouped answer (types, syntax sugar, runtime/performance, error-handling changes) rather than a random list, plus at least one feature you have actually used and why it helped.

Common mistakes

  • Listing enums or readonly properties as 8.0 features (they arrived in 8.1)
  • Claiming JIT speeds up typical web requests dramatically

Follow-up questions

  • Which 8.0 change broke code during your upgrade?
  • When would JIT actually help?

More most-asked PHP 8 questions

← All PHP 8 questions