PHP 7 interview question · Most asked

What is the difference between `==` and `===` in PHP?

Summary

== compares values after type juggling; === compares both value and type without conversion.

Longer Answer

'1' == 1 is true but '1' === 1 is false. For objects, == checks same class and equal properties, while === checks it's the same instance. Prefer === by default; it's clearer and avoids security bugs.

Key Points

  • == loose, converts types
  • === strict, no conversion
  • Objects: === means same instance

More most-asked PHP 7 questions

← All PHP 7 questions