我正在尝试根据可用的变量进行电子邮件更改。
总共有6个操作ID,但是20(代码中显示的那个)需要机器代码,而不像其他操作。
$email =
if ($OperationID == 20)
{
'Machine: '.$machCode."\r\n".
}
"JobID: ".$jobid."\r\n" .
"PartID: ".$part_id."\r\n" .
"\nNote: ".$message."\r\n";
@mail($email_to, $email_subject, $email);
如果没有“if
声明”,则可以发送类似以下内容的电子邮件
Machine:
JobID: 123456789
PartID: 123456789
Note: Test
我不想要这个,因为'machine'旁边有一个空格。我希望删除机器行,除非显然OperationID
为20.所以电子邮件如下所示:
JobID: 123456789
PartID: 123456789
Note: Test
如何才能使机器线仅在“操作”等于20?
时激活我目前收到此错误
`解析错误:语法错误,第21行/var/www/ps_t/send_form_email.php中的意外T_IF调用堆栈:0.0004 656768 1. {main}()/var/www/ps_t/punch.php:0 `使用上面使用的代码。
提前致谢。
答案 0 :(得分:2)
试试此代码
$email = "";
if ($OperationID == 20)
{
$email .= 'Machine: '.$machCode."\r\n";
}
$email .= "JobID : ".$jobid."\r\n" .
"PartID: ".$part_id."\r\n" .
"\nNote: ".$message."\r\n";
@mail($email_to, $email_subject, $email);
答案 1 :(得分:1)
尝试一下这个:
$email = '';
if ($OperationID == 20)
{
$email .= 'Machine: '.$machCode."\r\n";
}
$email .= "JobID: ".$jobid."\r\n" .
"PartID: ".$part_id."\r\n" .
"\nNote: ".$message."\r\n";
@mail($email_to, $email_subject, $email);
答案 2 :(得分:0)
试试这个:
if ($OperationID == 20)
{
$email = "Machine: ".$machCode."\r\n".
"JobID: ".$jobid."\r\n" .
"PartID: ".$part_id."\r\n" .
"\nNote: ".$message."\r\n";
@mail($email_to, $email_subject, $email);
}
else
{
$email = "JobID: ".$jobid."\r\n" .
"PartID: ".$part_id."\r\n" .
"\nNote: ".$message."\r\n";
@mail($email_to, $email_subject, $email);
}