0

我有这个条件:

if (isset($_REQUEST['altgeraet'])) {
    $Altgeraet = 'OK';
} else {
    $Altgeraet = 'NOK';
}

我想在 SQL 表Host_alt中的值“KeinAlterHost”是

$Altgeraet = 'OK'

这是我尝试过的,但没有奏效:

if (isset($_REQUEST['altgeraet']) 
        OR ($resultarray['Hostname_alt'] == "KeinAlterHost")) {
    $Altgeraet = 'OK';
} else {
    $Altgeraet = 'NOK';
}

那么这个设置对吗?我用array_key_exists

if ((isset($_REQUEST['altgeraet']) OR (array_key_exists('KeinAlterHost',$resultarray['Hostname_alt'])) {
        $Altgeraet = 'OK';
        } else {
        $Altgeraet = 'NOK';
        }
4

2 回答 2

0

The isset isn't quit right...

if (isset($_REQUEST['altgeraet']) OR ($resultarray['Hostname_alt'] == "KeinAlterHost")) {
    $Altgeraet = 'OK';
} else {
    $Altgeraet = 'NOK';
}

You need to quit it earlyer:

if (isset($_REQUEST['altgeraet']) OR ($resultarray['Hostname_alt'] == "KeinAlterHost")) {
    $Altgeraet = 'OK';
} else {
    $Altgeraet = 'NOK';
}

Because it checks if the request isset, and the hostname isset at you're old code. by the new one, it checks if the request isset, if not check if hostname == keinalterhost and then do the stuff...

于 2012-10-01T13:20:50.480 回答
0

您需要一个用于 OR 的管道

所以代码将是这样的:

if (isset($_REQUEST['altgeraet']) || ($resultarray['Hostname_alt'] == "KeinAlterHost"))
于 2012-10-01T13:11:21.000 回答