Home  >  Article  >  Backend Development  >  The difference between empty and isset toner empty running on empty textutils.isempty

The difference between empty and isset toner empty running on empty textutils.isempty

WBOY
WBOYOriginal
2016-07-29 08:48:471074browse

I have never understood these two functions very well. I will write a small program to deepen my understanding!

empty是什么意思啊,err empty response,isempty,empty音译歌词,empty sky,empty winner,empty怎么读,empty 台式电脑,empty string,php empty,empty的反义词,isempty函数,toner empty,running on empty,textutils.isempty

<?<span>php

</span><span>/*</span><span>*
*    isset  &mdash; 检测变量是否设置
*    如果 变量 存在则返回 true, 否则返回 false
*
*    empty  &mdash; 检查一个变量是否为空
*    如果 变量 是非空或非零的值,则 empty() 返回 false
*</span><span>*/</span><span>$is_var</span> = ''<span>;

</span><span>if</span>(<span>isset</span>(<span>$is_var</span><span>)) {
    </span><span>echo</span> "变量存在!<br />"<span>;
} </span><span>else</span><span> {
    </span><span>echo</span> "变量不存在!<br />"<span>;
}

</span><span>if</span>(<span>empty</span>(<span>$is_var</span><span>)) {
    </span><span>echo</span> "变量为空!<br />"<span>;
} </span><span>else</span><span> {
    </span><span>echo</span> "变量不为空!<br />"<span>;
}

</span>?>

empty是什么意思啊,err empty response,isempty,empty音译歌词,empty sky,empty winner,empty怎么读,empty 台式电脑,empty string,php empty,empty的反义词,isempty函数,toner empty,running on empty,textutils.isempty

Output result:

The variable exists!
The variable is empty!

The above has introduced the difference between empty and isset, including the content of empty. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn