NULL ¶
特殊的 null 值表示一个变量没有值。NULL 类型唯一可能的值就是 null。
在下列情况下一个变量被认为是 null:
- 被赋值为
null。 - 尚未被赋值。
- 被 unset()。
转换到 NULL ¶
Warning
本特性已自 PHP 7.2.0 起废弃。强烈建议不要使用本特性。
使用 (unset) $var 将一个变量转换为 null 将不会删除该变量或 unset 其值。仅是返回 null 值而已。
Note: empty array is converted to null by non-strict equal ‘’ comparison. Use is_null() or ‘=’ if there is possible of getting empty array.
$a = array();
$a == null <== return true $a === null < == return false is_null($a) <== return false
Note: Non Strict Comparison ‘==’ returns bool(true) for
null == 0 <-- returns true
Use Strict Comparison Instead
null === 0 <-- returns false
https://www.php.net/manual/zh/language.types.null.php
