🐘 PHP
Beginner
What is the difference between null, false, and empty string in PHP?
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.