为了账号安全,请及时绑定邮箱和手机立即绑定

如果变量为空,则不要在电子邮件中包含表格 - PHP

如果变量为空,则不要在电子邮件中包含表格 - PHP

PHP
UYOU 2021-11-05 10:30:46
我有 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>";
查看完整描述

1 回答

?
牧羊人nacy

TA贡献1862条经验 获得超7个赞

只需添加 if with empty($ans01) 等于 not。代码:


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>";

}


查看完整回答
反对 回复 2021-11-05
  • 1 回答
  • 0 关注
  • 137 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信