如何修复未定义的索引警告?

时间:2014-05-07 19:48:38

标签: php

这是我得到的警告。

未定义索引:第8行/var/www/html/ies.aacrao.org/apply/begin.php中的errormsg

在这行代码上:

if ($_GET['errormsg'] == "no_appid") {

$_SESSION['errormsg'] = "There was a problem with your application.  Please reenter all data.";

}

希望有人能帮助我。

2 个答案:

答案 0 :(得分:0)

表示未设置$_GET['errormsg']。你可以这样检查:

if (isset($_GET['errormsg']) && $_GET['errormsg'] == "no_appid") {
}

答案 1 :(得分:0)

您可以与isset一样查看

if (isset($_GET['errormsg']) && $_GET['errormsg'] == 'no_appid') {
    $_SESSION['errormsg'] = "There was a problem with your application.  Please reenter all data.";
}

查看php isset