1
Good Afternoon,
How to Make an if within variable value assignment.
$html ='
<body>
<table width="100%" style="background:#00aeef;">
<tr><td>
<table width="596" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Arial;background:#FFF;">
<tr>
<td height="78" colspan="2"><img name="index_r1_c1" src="email/img/index_r1_c1.png" width="595" height="78" id="index_r1_c1" alt="" /></td>
</tr>
<tr>
<td height="200" colspan="2" valign="top" style="font-size:16px;padding:30px 15px;font-family:Arial;"><h3>Olá,</h3>
<h3> O Cliente abaixo se interessou por um de seus itens publicados no jornal, seguem os dados dele:</h3>
<strong>Nome</strong>: '.$nome.'<br>'.
if($email != ""){
<strong>E-Mail</strong>: '.$email.'<br>;
}
if($whatsapp != ""){
<strong>WhatsApp</strong>: '.$whatsapp.'<br>;
}.'
<h3>Segue abaixo informações sobre o imóvel:</h3>
In case $html is mounting the body of an email and I would like it to appear only the field ($email, $Whatsapp) if it is different from empty.
Make the IF separate, within other variables, and put only the result.
– William Aparecido Brandino
The simplest is not to do this. You can concatenate the desired value with the variable within the
if, but if you want, you can use the ternary operator.– Woss