🐘 PHP Beginner

What is the difference between null, false, and empty string in PHP?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex PHP topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

In PHP, null represents the absence of a value — a variable that has been explicitly set to null, not yet assigned, or unset. false is a boolean value representing logical falsehood. Empty string ("") is a string with zero characters. While all three are "falsy" (evaluate to false in a boolean context), they are distinct values: is_null(null) is true, is_null("") is false. The empty() function returns true for all of them as well as for 0, "0", []. Always use strict comparisons (===) or type-specific functions (is_null(), is_bool()) to distinguish between them.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex PHP answers easy to follow.