我怎样才能添加这个条件?

How can I add this condition?

$test1 = 7;
$test2 = 1;
$test3 = 3;
$total = $test1 + $test2 + $test3;

$isPassed = ( $total >= 10 && $test >= 2 ) ? true : false;

echo ( $isPassed ) ? "Passed" : "Not Passed";

Variable $test

我想第二个条件是这样的,如果学生在其中一项考试中的成绩低于或等于 2,则他不能通过考试. 我该如何编码?

您可以将它们全部添加到一个数组中,然后使用 min()

//preferably store all of the test scores in an array
//instead of a separate variable for each one.
$test_scores = [$test1, $test2, $test3];

$total = array_sum($test_scores);

//you don't need the ternary because this expression will
//return true/false anyways
$isPassed = ($total >= 10 && min($test_scores) > 2);