What is a null value (NULL)?
A null value, like its name, indicates that a variable has no value. A null value (NULL) is not case-sensitive, that is, NULL is the same as null or NULL.
There are three scenarios in which null values are given in PHP:
The first type:
has not been assigned a value
<?php$a;var_dump ($a);? >
Code Run Result:
The second type:
is assigned a value of NULL.
<?php$nu=null;var_dump ($NU);? >
Code Run Result:
The third type:
Variables processed by the unset () function
<?php$name = ' Felipe '; Var_dump ((unset) $name);? >
Code Run Result:
Instance
The string string1 is assigned a value of null,string2 and is not declared and assigned at all, so the output is null, and the last string3, although given the initial value, is also null after being processed by the unset () function. The function of the unset () function is to remove variables from memory. The code is as follows:
<?phpheader ("Content-type:text/html;charset=utf-8"); Echo "variable ($string 1) is directly assigned null"; $string =null; $string 1 is assigned the null value $string3= "str"; $string 3 is assigned Strif (Is_null ($strig 1=null)) { //determines if $string1 is empty echo ' String=null ';} Echo ' <p> ', echo ' variable ($string 2) not assigned '; if (Is_null ($string 2=null)) { //Determine if $string1 is empty echo ' String=null ' ;} Echo ' <p> ', Echo ' was released by Unset ($string 3): '; unset ($string 3), if (Is_null ($string 3=null)) {//To determine if $string1 is empty echo ' String=null ';}? >
Code Run Result:
The Is_null function is used to determine if a variable is null, as we'll see later, now that this function returns a Boolean, if the variable is null, returns True, otherwise false. The unset () function is used to destroy known variables.
In the next section, we explain "how to convert PHP data types".