Example 1 — Null Versus Other Values
Check null, zero and an empty string to see that only null counts as null.
<?php
$a = null;
$b = 0;
$c = '';
var_dump(is_null($a));
var_dump(is_null($b));
var_dump(is_null($c)); How It Works
- $a holds null. It has no value at all, so is_null() returns true.
- $b holds 0. Zero is an integer value, so the result is false.
- $c holds an empty string. It is a string with no characters, which is not null.
- Only the first check is true. is_null() never treats empty-looking values as null.

