日期:2014-05-17  浏览次数:20391 次

判断php变量是否定义,是否为空

isset() 【1】

Returns?TRUE?if?var?exists and has value other than?NULL,?FALSE?otherwise.

输入可以是多个变量,只有所有的变量为真的时候,返回真

empty()【2】

Returns?FALSE?if?var?has a non-empty and 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?is?null?,?FALSE?otherwise.

?

?

?? A variable is considered to be?null?if:

  • it has been assigned the constant?NULL.