检查其中一个表单输入字段在php中不为空

Could you please inform how to check one of the form input fields is not empty in php, no matter what input field names are.

<form name="form1" method="POST">
<input type="text" name="a">
<input type="text" name="b">
</form>

However, please do not inform me the following codes as I know.

 if ($_POST["a"] != "" || $_POST["b"] != "")
 { [proceed....] }

Loop through the POST array and test the value like this perhaps

if( $_SERVER['REQUEST_METHOD']=='POST' ){
    foreach( $_POST as $field => $value ){
        if( !empty($value) ){
            exit( $field . 'is NOT empty' );
        }
    }
}

The if statement can get quite long if there are multiple input fields.

You should use array_filter() function on POST data.

Try this:

 if (array_filter($_POST)) {
    echo "Proceed";
 } else {
    echo "One of the fields is blank";
 }