The null type has exactly one value: null. The constant is case-insensitive, so NULL denotes the same value. An undefined or unset variable resolves to null, but reading an undefined variable directly also issues a warning.
null is distinct from false, 0, and the empty string.
Assigning null and removing a variable with unset are different operations.
Check whether a value is set
isset returns false when a variable is undefined or has the value null. It returns true for an existing variable holding an empty string. This excerpt retains the manual's null check.
unset removes a variable; it is a language construct rather than a cast. Use is_null to check whether an existing value is null. isset alone cannot distinguish an undefined variable from a variable explicitly assigned null.
Recognize null, unset values, isset, and the distinction from false and an empty string. Selected scope only; later chapter detail follows the complete PHP program catalog.
Recognize null, unset values, isset, and the distinction from false and an empty string. Selected scope only; later chapter detail follows the complete PHP program catalog.
Recognize null, unset values, isset, and the distinction from false and an empty string. Selected scope only; later chapter detail follows the complete PHP program catalog.
Recognize null, unset values, isset, and the distinction from false and an empty string. Selected scope only; later chapter detail follows the complete PHP program catalog.
Recognize null, unset values, isset, and the distinction from false and an empty string. Selected scope only; later chapter detail follows the complete PHP program catalog.
Credits and license
PHP Documentation Group. CC BY 3.0 or later.
Adapted and condensed from the cited pinned PHP manual sources by Kodivo with AI assistance. Examples preserve complete source listings or explicitly identified excerpts. This is not an official PHP course. This revision adds original Kodivo worked examples and artwork prepared with AI assistance; the cited manual remains the source for the technical rules.