php empty()或isset()检查多个变量
我用 为了检查登录文件是否已填充,当我检查1个变量时,它可以工作,但当我使用php empty()或isset()检查多个变量,php,Php,我用 为了检查登录文件是否已填充,当我检查1个变量时,它可以工作,但当我使用 if(!empty($_POST['login'])){ } 如何检查2个变量,我发现isset也只支持1个变量使用逻辑and运算&&以及两个空调用,如下所示: if(!empty($_POST['login'],$_POST['password'] )){ } 尝试使用以下方法: if( !empty( $_POST['login']) && !empty( $_POST['password'])
if(!empty($_POST['login'])){
}
如何检查2个变量,我发现isset也只支持1个变量使用逻辑and运算&&以及两个空调用,如下所示:
if(!empty($_POST['login'],$_POST['password'] )){
}
尝试使用以下方法:
if( !empty( $_POST['login']) && !empty( $_POST['password'])) {
// $_POST['login'] and $_POST['password'] are both not empty
}
你可以这样称呼它:!isempty$\u POST['login'],$\u POST['password']
我还没有测试代码,但是应该可以isset将接受多个变量-您的意思是var_dumpisset$a,$b;//TRUE?如果同时设置了$a和$b,则设置$a和$b将返回TRUE;这就是你的意思吗?
function isempty(){ // Function checks if all of the given arguments are empty
$empty = true;
$numargs = func_num_args(); // get the number of given Arguments
$arg_list = func_get_args(); // get the given Arguments
for ($i = 0; $i < $numargs; $i++) {
$empty = $empty && empty($arg_list[$i]);
}
return $empty;
}