在多个值上设置

Geo*_*iuc 1 html php forms post isset

如果同时设置,我想检查多个值.我从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.

那么为什么我的代码总是打印发送的值并且从不打印'否'?

PHP

if ( isset( $_POST['thread'],
        $_POST['winkey'],
        $_POST['dkey'],
        $_POST['winrew'],
        $_POST['drew'] )===true ) {
    echo $_POST['thread'];
    echo $_POST['winkey'];
    echo $_POST['dkey'];
    echo $_POST['winrew'];
    echo $_POST['drew'];
}
else echo 'no';
Run Code Online (Sandbox Code Playgroud)

HTML

<form action="class.php" method="POST">
thread link:<br>
<input type="text" name="thread" >
<br>
win key:<br>
<input type="text" name="winkey" >
<br>
double key:<br>
<input type="text" name="dkey" >
<br>
winrew:<br>
<input type="text" name="winrew" >
<br>
double rew:<br>
<input type="text" name="drew" >
<br>
<input type="checkbox" name="banlist" value="ban">Include banlist<br>
<br>
<input type="submit" value="Submit">
</form> 
Run Code Online (Sandbox Code Playgroud)

jer*_*oen 5

提交表单后$_POST,将立即设置您提及的所有变量.如果POST未提出请求,则不会设置任何请求.

我认为你正在寻找empty()测试是否有任何变量是空的.