只需多个$ _POST值[关闭]

if(isset($_POST["value1"]) && $_POST["value1"] != "" 
    && isset($_POST["value2"]) && $_POST["value2"] != "" 
    && isset($_POST["value3"]) && $_POST["value3"] != "") {

}

I send text type data using ajax and in the backend I've to validate like this. Is there any other better way to do that?

Use the empty function.

if(!empty($_POST["value1"]) && !empty($_POST["value2"]) && !empty($_POST["value3"])) {
}

PHP documentation

Returns FALSE if var exists and has a non-empty, non-zero value. Otherwise returns TRUE.

The following things are considered to be empty:

"" (an empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
$var; (a variable declared, but without a value)

You can use the empty function.

instead of isset and checking for "" you could simply use empty:

 if(!empty($_POST["value1"]) && !empty($_POST["value2"])){}