isset() 【1】
Returns TRUE if var exists and has value otherthan NULL , FALSE otherwise.
输入可以是多个变量,只有所有的变量为真的时候,返回真
empty()【2】
Returns FALSE if var has a non-emptyand non-zero value.
The following things are considered to be empty:
"" (an empty string)
0 (0 as an integer)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)
输入只能是一个变量
is_null() 【3】
Returns TRUE if var isnull , FALSE otherwise.
A variable is considered to be null if:
it has been assigned the constant NULL .
it has not been set to any value yet.
it has been unset().
使用 PHP 函数对变量$x进行比较表达式gettype()empty()is_null()isset()if($x) Boolean$x = ""; stringTRUE FALSE TRUE FALSE $x = null; NULLTRUE TRUE FALSE FALSE var $x; NULLTRUE TRUE FALSE FALSE $xis undefinedNULLTRUE TRUE FALSE FALSE $x = array(); arrayTRUE FALSE TRUE FALSE $x = false; booleanTRUE FALSE TRUE FALSE $x = true; booleanFALSE FALSE TRUE TRUE $x = 1; integerFALSE FALSE TRUE TRUE $x = 42; integerFALSE FALSE TRUE TRUE $x = 0; integerTRUE FALSE TRUE FALSE $x = -1; integerFALSE FALSE TRUE TRUE $x = "1"; stringFALSE FALSE TRUE TRUE $x = "0"; stringTRUE FALSE TRUE FALSE $x = "-1"; stringFALSE FALSE TRUE TRUE $x = "php"; stringFALSE FALSE TRUE TRUE $x = "true"; stringFALSE FALSE TRUE TRUE $x = "false"; stringFALSE FALSE TRUE TRUE (上表没有找到原始来源,谁知道请告诉我)
如果变量是一个object该如何呢?
表达式gettype()empty()is_null()isset()if($x) Boolean$x = new object() objectFALSEFALSETRUE TRUE 参考:
【1】http://php.net/manual/en/function.isset.php
【2】http://www.php.net/manual/en/function.empty.php
【3】http://www.php.net/manual/en/function.is-null.php
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com