Home >Backend Development >PHP Problem >What does null mean in php
null in php means "empty", which is a special mark usually used to indicate that a variable has no value; when the variable is directly assigned to null, when the declared variable has not been assigned a value, or when the variable is unset( ) function is destroyed, the value of a variable will be considered to be null.
The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer
null in php is What does it mean
1: What does the null value mean?
NULL is a special mark in php. The NULL value indicates that a variable has no value. The NULL type is the only possible one. The value is NULL.
A variable is considered NULL under the following circumstances:
1. It is assigned a value of NULL.
2. It has not been assigned a value.
3. Be unset().
2: Syntax
The NULL type has only one value, which is the case-insensitive constant NULL.
<?php $var = NULL; ?> is_null ( mixed $var ) : bool
Returns TRUE if var is null, otherwise returns FALSE.
Look at the NULL type to know when a variable is considered NULL.
Three: Converting to NULL
Using (unset) $var Converting a variable to null will not delete the variable or unset its value. Just returns a NULL value.
Note: Empty arrays are converted to null via non-strict equality '==' comparisons. If it is possible to get an empty array, use is_null() or '==='. $a = array();
$a == null <== return true $a === null < == return false is_null($a) <== return false
NULL should represent no value and not be considered the value itself.
NULL is a null bit, this is missing information, talking about "null value" is a semantic awkwardness, but if a variable can exist without a value, then the language and implementation must have something to represent this situation.
If you are interested, you can click on "PHP Video Tutorial" to learn more about PHP knowledge.
The above is the detailed content of What does null mean in php. For more information, please follow other related articles on the PHP Chinese website!