#$abc = "abc";
$def;
#var_dump(isset($abc));
//var_dump(empty($def));
//var_dump(false);
//var_dump(empty (''));
var_dump(isset($def));
var_dump(is_null($def));
#var_dump(isset($def));
#1.php data variables are similar to C/C++ Declaration and definition of variables in?
#There are no declarations in php, only undefined and defined
#2. What is the definition of php variables? Is it $def; or $abc = "abc"; ?
# The definition of a variable in php is to directly assign a value to the variable when writing the variable, that is, $abc="abc"; This is called variable definition
# If $def, What will be displayed? Let’s do an experiment var_dump($def);
#Output:
#Notice: Undefined variable: def in C:UserslsqbuptDesktopabcdefg.php on line 9
#NULL
# $def; This is called a variable being undefined
#Let’s do it again Do an experiment
# If $def = null; var_dump($def);
# It will output NULL and there will be no Notice
#
#3.isset() is_null() empty() and the variable itself as When judging if($abc) or if($def), is there any difference between these functions?
#4.What is null? Is it case sensitive?
#NULL empty type
#null is not case-sensitive, the NULL type has only one value, indicating that a variable has no value, the variable is considered NULL in the following three situations #1. Assigned to NULL
#2. Not yet assigned a value
#3. Being unset();
The function of the #is_null() function can still be seen literally, it is quite simple
#isset() and is_null() are a pair
#isset() function: when { Undefined, such as $def} and {the variable itself is NULL, such as $def = null;}, it returns false and there is no notice. Others return true
#empty() function: when '',"",0,'0 ' ,"0" ,null ,false ,array(), undefined variables are returned as true
#is_null() function, when {undefined, such as $def} and {the variable itself is NULL, such as $def = null ;} returns true and others returns false
#is_null() function will have a notice for {undefined, such as $def}, but there will be no notice for {the variable itself is NULL, such as $def = null;} {I found this function It's a pair with isset()}
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the variable issues in PHP, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.