日期:2014-05-16  浏览次数:20422 次

php手册
http://php.net/manual/zh/function.isset.php

代码
<?php

$var = '';

// 结果为 TRUE,所以后边的文本将被打印出来。
if (isset($var)) {
    echo "This var is set so I will print.";
}

// 在后边的例子中,我们将使用 var_dump 输出 isset() 的返回值。
// the return value of isset().

$a = "test";
$b = "anothertest";

var_dump(isset($a));      // TRUE
var_dump(isset($a, $b)); // TRUE

unset ($a);

var_dump(isset($a));     // FALSE
var_dump(isset($a, $b)); // FALSE 这个b在这里有什么作用?b貌似没有被销毁。

$foo = NULL;
var_dump(isset($foo));   // FALSE

?>

var_dump(isset($a, $b)); // FALSE 这个b在这里有什么作用?b貌似没有被销毁。

------解决方案--------------------
isset(mixed value)//isset可以设定多变量检查,当$a,$b都存在时为true。

http://www.php.net/isset

If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set. Evaluation goes from left to right and stops as soon as an unset variable is encountered.
------解决方案--------------------
isset()-检测变量是否被设置

bool isset(mixed $var [, mixed $...]),检查变量是否被设置,并且不是NULL。var,要检测的变量,...其他变量,允许有多个变量。

返回值:如果var存在并且不是NULL,则返回TRUE,否则返回FALSE.

如果已经使用unset()释放一个变量之后,它将不再是isset().如果使用isset测试一个被设置成NULL的变量,返回false.

同时注意,一个NULL字节("\0")(例如$foo=NULL;isset($foo);是FALSE)并不等同于PHP的NULL常数(例如$foo='';isset($foo);是TRUE)。