我正在運行檢查輸入空功能,但問題是該數組中的變量不工作。數組顯示空不給任何值
這裏是我的代碼:
$name = $email = $message = $result = "";
function has_presense($input){
if(empty($input)){
return $result = ucwords($input) ." is missing!";
}
}
if(isset($_POST['send'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$input = array($name,$email,$message);
foreach($input as $key => $value){
if(has_presense($key)){
$result = $value . "is missing";
}
}
}
結果:
Array ([0] => [1] => [2] =>)
它顯示空數組是什麼問題了。
哪裏是表格代碼。你的表單代碼有問題。把你的完整代碼(表格+ php) –
你能提供表單提交的代碼嗎? –
先嚐試echo $ name,$ email,$ message並檢查你的變量值。它是空白的嗎? –