What is the difference between isset(), empty(), and is_null()?

Last updated 15 June 2026

All three test variables but answer different questions: isset() asks "does it exist and is it non-null?", empty() asks "is it falsy (or missing)?", and is_null() asks "is it exactly null?".

  • isset(): Returns true if the variable is declared and not null; safe on undefined variables/array keys without a warning.

  • empty(): Returns true for any falsy value: 0, "", "0", null, false, empty array, and undefined variables.

  • is_null(): Returns true only when the value is exactly null; warns if the variable was never defined (it's a normal function, not a language construct).

  • Practical gotcha: A variable holding 0 is isset() true but empty() true too, so don't use empty() when 0 is a valid value.

  • https://github.com/mingyun/mingyun.github.io/issues/92
  • https://www.geeksforgeeks.org/quizzes/php-forms-quiz/
  • https://stackoverflow.com/questions/12375833/isset-vs-empty-vs-is-null
  • https://github.com/mingyun/mingyun.github.io/issues/121
  • https://github.com/335348684/php-engineer-interview-questions
  • https://www.interviewbit.com/magento-2-interview-questions/
All PHP interview questions