-1
if(!empty($_POST['login'])){
}
用於檢查登錄的文件被填滿,當我檢查1個變量,但沒有工作,當我用
工作if(!empty($_POST['login'],$_POST['password'])){
}
如何檢查2個變量,我看到isset()函數也只支持1個變量
if(!empty($_POST['login'])){
}
用於檢查登錄的文件被填滿,當我檢查1個變量,但沒有工作,當我用
工作if(!empty($_POST['login'],$_POST['password'])){
}
如何檢查2個變量,我看到isset()函數也只支持1個變量
使用邏輯與操作(&&
)有兩個電話一起empty()
,像這樣:
if(!empty($_POST['login']) && !empty($_POST['password'])) {
// $_POST['login'] and $_POST['password'] are both not empty
}
嘗試使用此:
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;
}
你可以這樣調用:!isempty($_POST['login'], $_POST['password'])
我沒有測試的代碼,但它應該是罰款
isset將採取多變量 - http://php.net/manual/en/function.isset.php – andrewsi
你的意思是'var_dump(isset($ a,$ b)); // TRUE'? – Wizard
如果$ a和$ b都被設置,'isset($ a,$ b)'將返回true;這是你的意思嗎? – andrewsi