当前位置:网站首页>Empty, isset and is of PHP_ Null difference

Empty, isset and is of PHP_ Null difference

2022-06-22 03:52:00 Healthy brick carrier

PHP Three functions are provided for testing variable values , Namely isset(),empty(),is_null(), They all return Boolean values , But there are differences .

View through the following table :

 

Contrast item  isset() Method empty() Method is_null Method
""( An empty string )trueturefalse
" "( A space )truefalsefalse
FALSEtruetruefalse
TRUEtruefalsefalse
array()( An empty array )truetruefalse
NULLfalsetruetrue
"0"( character string 0)truetruefalse
0( integer 0)truetruefalse
0.0( floating-point )truetruefalse
$a( Unassigned variables )falsetruefalse

1、isset() Function is used to detect whether a variable has been declared and the value is not NULL, That is, only when the value is not NULL Returns true when

2、empty() It is used to check whether a variable is empty. If there are the following conditions, it returns the true value :

    1) An empty string

    2)false

    3) An empty array

    4)NULL

    5)0

    6)0.0

    7)unset The next variable

    8) character string 0

3、is_null() Used to determine whether the variable content is null value , The only condition for returning a true value is that the variable is null when , So he is. isset() The inverse function of , It can also be seen from the above table

 

 

原网站

版权声明
本文为[Healthy brick carrier]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211630247844.html