is_null
Checks whether a value is null.
Syntax
is_null(mixed $value): boolParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | The value to check. |
Return value
bool`true` if the value is `null`.
Examples
Only null gives true:
<?php
var_dump(is_null(null));
var_dump(is_null(0));
var_dump(is_null(''));Output:
bool(true)
bool(false)
bool(false)The same with a strict comparison:
<?php
$result = null;
var_dump($result === null);Output:
bool(true)Notes
The comparison $value === null does the same and is more common.
See also
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.