PHP中的"isset()"和“!empty()"有什么区别? [英] What's the difference between 'isset()' and '!empty()' in PHP?

查看:68
本文介绍了PHP中的"isset()"和“!empty()"有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白isset()!empty()之间的区别.

I don't understand the difference between isset() and !empty().

因为已经设置了变量,这与不为空一样吗?

Because if a variable has been set, isn't it the same as not being empty?

推荐答案

ISSET 检查变量是否已设置.换句话说,它将检查变量是否为除NULL以外的任何值或未分配值.如果变量存在并且具有非NULL的值,则ISSET返回TRUE.这意味着设置了分配了",0,"0"或FALSE的变量,因此对于ISSETTRUE.

ISSET checks the variable to see if it has been set. In other words, it checks to see if the variable is any value except NULL or not assigned a value. ISSET returns TRUE if the variable exists and has a value other than NULL. That means variables assigned a "", 0, "0", or FALSE are set, and therefore are TRUE for ISSET.

检查变量是否为空.空解释为:"(空字符串),0(整数),0.0(浮点数),"0"(字符串),NULL,FALSE,array()(空数组)和"$ var;" (已声明的变量,但在类中没有值.

EMPTY checks to see if a variable is empty. Empty is interpreted as: "" (an empty string), 0 (integer), 0.0 (float)`, "0" (string), NULL, FALSE, array() (an empty array), and "$var;" (a variable declared, but without a value in a class.

有关更多信息,请参见这篇文章

For more information, see this article

这篇关于PHP中的"isset()"和“!empty()"有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆