Php 一个if循环中的多个isset查询

Php 一个if循环中的多个isset查询,php,post,boolean-logic,isset,Php,Post,Boolean Logic,Isset,我正在尝试获取以下查询: 如果存在值A和值B,或者存在值A或存在值B-->请执行某些操作 当其中一个字段中有一个值正确工作时,但当两个字段都为空时,仍然可以明显看出存在某些内容 葡萄酒可能与自动完成有关吗 $checkVIN1 = mysql_query("SELECT vhl_vin FROM vhldescription"); $num_rows = mysql_num_rows($checkVIN1); $i = 0; echo "<script>$(function() {v

我正在尝试获取以下查询: 如果存在值A和值B,或者存在值A或存在值B-->请执行某些操作

当其中一个字段中有一个值正确工作时,但当两个字段都为空时,仍然可以明显看出存在某些内容

葡萄酒可能与自动完成有关吗

$checkVIN1 = mysql_query("SELECT vhl_vin FROM vhldescription");
$num_rows = mysql_num_rows($checkVIN1);
$i = 0;
echo "<script>$(function() {var availableTags = [";
while($checkVIN2 = mysql_fetch_array($checkVIN1, MYSQL_ASSOC))  {   $i++;   echo "\"" . <br />$checkVIN2['vhl_vin'] . "\",";
    if ($i == ($num_rows))  {   echo "\"" . $checkVIN2['vhl_vin'] . "\"";   }   }
echo "];$( \"#tags\" ).autocomplete({source: availableTags});});</script>";
<input id="tags" name="A" class="le-input">
这个怎么样

<?php
$a;
$b;


if((isset($a) or isset($b)) and !(empty($a) or empty($b))){
    echo "do something";    
}else{
    echo "do nothing";
}

尝试将代码更改为:

$postVars = array('A', 'B');
$things = array();
foreach($postVars as $postVar) {
    if( isset($_POST[$postVar]) && !empty($_POST[$postVar]) )
    {
        $things []= $_POST[$postVar];
    }
}

if( empty($things) ) {
    echo "it's empty<br />";
} else {
    echo "there is something: "
         . join(', ', array_map(function($str) {
                                    return htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8');        
                                },
                                $things)) . '.';
}

在其他条件下收紧支票。
$postVars = array('A', 'B');
$things = array();
foreach($postVars as $postVar) {
    if( isset($_POST[$postVar]) && !empty($_POST[$postVar]) )
    {
        $things []= $_POST[$postVar];
    }
}

if( empty($things) ) {
    echo "it's empty<br />";
} else {
    echo "there is something: "
         . join(', ', array_map(function($str) {
                                    return htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8');        
                                },
                                $things)) . '.';
}