A null value, like its name, indicates that a variable has no value. Null is case-insensitive, that is, null is the same as NULL or Null.
What is a null value )?
A null value, like its name, indicates that a variable has no value. Null is case-insensitive, that is, null is the same as NULL or Null.
There are three cases where null values are granted in PHP:
First:
Not assigned
Code running result:
Second:
The value is NULL.
Code running result:
Third:
Variable processed by the unset () function
Code running result:
Instance
The string1 string is assigned null, and string2 has no declaration or assignment at all. Therefore, the output is null. although string3 is assigned an initial value, it is processed by the unset () function, also changed to null type. The unset () function is used to delete variables from memory. The code is as follows:
'; Echo' variable ($ string2) is not assigned '; if (is_null ($ string2 = null )) {// Determine whether $ string1 is empty echo 'string = Null';} echo''; Echo' variable released by unset () ($ string3): '; unset ($ string3); if (is_null ($ string3 = null )) {// Determine whether $ string1 is empty echo 'string = Null';}?>
Code running result:
The is_null function is used to determine whether the variable is null. as we will talk about later, we will first understand that this function returns a boolean type. if the variable is null, true is returned, otherwise, false is returned. The unset () function is used to destroy known variables.
In the next section, we will explain how to convert the PHP Data type ".
The above is php: detailed description of null data type instances. For more information, see other related articles in the first PHP community!