出现此错误:
代码:
$value = ($_POST['formEnquiry']) ? ($_POST['formName']) ? ($_POST['formTitle']) : '';
答案 0 :(得分:0)
您似乎尝试使用两个三元运算符,但未指定" else子句"对于第一个。打破代码:
$value = ($_POST['formEnquiry'])
? ($_POST['formName'])
? ($_POST['formTitle'])
: ''
// You're missing a ':' (else) statement here, like
: ''
;
将其编写为程序代码,它看起来像这样:
if ($_POST['formEnquiry']) {
if ($_POST['formName']) {
$value = $_POST['formTitle'];
} else {
$value = '';
}
} else {
// Because of the way an assignment through a ternary works,
// there needs to be an else here, since you already wrote $value =
// Without an else value, it would end up like $value = ;
$value = '';
}
答案 1 :(得分:0)
试试这个:
$value = ($_POST['formEnquiry']) ? ($_POST['formName']) ? ($_POST['formTitle']) : '' : '';