我正在努力了解这一点的区别:
if (isset($_POST['Submit'])) { //do something }
和
if ($_POST['Submit']) { //do something }
在我看来,如果$_POST [‘Submit’]变量为true,那么它被设置.为什么在这种情况下需要isset()函数?
因为
$a = array("x" => "0"); if ($a["x"]) echo "This branch is not executed"; if (isset($a["x"])) echo "But this will";
(另见http://hk.php.net/manual/en/function.isset.php和http://hk.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting)