PHP 7 interview question · Most asked

What were the headline improvements of PHP 7.0 over PHP 5.6?

Summary

PHP 7.0 roughly doubled performance and cut memory use thanks to the PHPNG engine rewrite, and added scalar type declarations, return types, ??, <=>, anonymous classes and the Throwable error hierarchy.

Longer Answer

The new engine (PHPNG, Zend Engine 3) reorganized internal data structures: zvals no longer need separate heap allocation for scalars, and hash tables became more compact. Real-world apps like WordPress served about twice as many requests per second.

Language-wise, PHP 7 introduced optional scalar type hints (int, float, string, bool), return type declarations, declare(strict_types=1), the null coalescing and spaceship operators, anonymous classes, random_bytes()/random_int(), and turned most fatal errors into catchable Error exceptions. The old mysql_* extension and ereg functions were removed.

Key Points

  • ~2x throughput, lower memory (PHPNG)
  • Scalar and return types, strict_types
  • ??, <=>, anonymous classes
  • Fatal errors become Error exceptions
  • Removed mysql_*, ereg, ASP tags

Explanation

What interviewers look for

Separating engine/performance changes from language features, and noting breaking removals.

Follow-up questions

  • Why was there no PHP 6?

More most-asked PHP 7 questions

← All PHP 7 questions