8. NULL data type
is a variable with no value. It is called a special data type in PHP.
A variable is null if,
It has been assigned the constant NULL
It has not been set to any value.
It has been unset()
Value NULL is case insensitive.
2. $var = NuLl;
3. echo var_dump($var);
6. echo var_dump($var1); //Will throw an Error NULL
8. echo "<br>";
9. $var2 ="Mike";
10. echo var_dump($var2);
13. echo var_dump($var2); //Will throw an Error NULL
Notice: Undefined variable: var1 in E:\xampp\htdocs\xampp\Tutorials\test.php on line 6
Notice: Undefined variable: var2 in E:\xampp\htdocs\xampp\Tutorials\test.php on line 13
As we can see $var is defined as NUll (as Null is case insensitive).
$var1 is undefined (variable is declare without assigning value to it is null)
$var2 is defined as Mike and later being uset using unset()
function, so it result to null.(this is called as
Casting variable to null