我有html表单,并通过php处理以发送电子邮件。如果变量($ ans01)为空,如何隐藏表格而不包含在电子邮件中?
$message .= '<table width="100%" rules="rows" style="border: 1px solid #0066cc;" cellpadding="5">';
$message .= "<tr><td colspan='2'>This line is question and answer is below?</td></tr>";
$message .= "<tr><td colspan='2' style='color:#0000FF;'><strong>" .$ans01. "</strong></td></tr>";
$message .= "</table><br>";
答案 0 :(得分:1)
如果与empty($ ans01)等于不等于,则添加。代码:
if (!empty($ans01)) {
$message .= '<table width="100%" rules="rows" style="border: 1px solid #0066cc;" cellpadding="5">';
$message .= "<tr><td colspan='2'>This line is question and answer is below?</td></tr>";
$message .= "<tr><td colspan='2' style='color:#0000FF;'><strong>" .$ans01. "</strong></td></tr>";
$message .= "</table><br>";
}
祝你好运! :D