在我的php邮件中回车问题

时间:2017-11-08 14:54:39

标签: php

我正在学习PHP语言,我的.langs文件和我的php邮件部分出现了问题。

根据邮件消息的部分如下所示:

$message = $outputlangs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);

我的.langs文件中有:

  

ExpenseReportWaitingForApprovalMessage = Une nouvelle note de frais est   en attente d'approbation sur notre ERP。\ n-   Utilisateur:%s \ n-Période:%s \ nCliquez ici pour afficher la note de   frais:%s。

当我发送电子邮件时,我明白了:

enter image description here

我的回车不起作用,我找不到解决这个问题的方法。

我试过了:

$message = $outputlangs->trans

但没有效果。

你有什么想法吗?

谢谢

编辑:

我试图从.langs文件中删除文本,我写了这个:

$corps = "Une nouvelle note de frais est en attente d'approbation sur notre ERP.\r\n- Utilisateur : %s\r\n- Période : %s\r\nCliquez ici pour afficher la note de frais: %s.";
$message = ($corps, $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);

但我得到空白页

1 个答案:

答案 0 :(得分:2)

我相信我看到了这个问题。也许(?)我不认识任何变性。你没有把它包括在内。

但是,如果你的langs文件中只有这个\n作为文字填充到$ message中...它只是将它直接转移到邮件正文中以获得面值。

你需要在你的langs文件中实际拥有真正的换行符......而不是它们的字符串文字。

尝试做:

$message = str_replace('\n',"\n",$message);

在发送邮件之前执行此操作。 (是的,str_replace中的第一个值是单引号,用实际替换文字。)

在您的第二次编辑中:

$corps = "Une nouvelle note de frais est en attente d'approbation sur notre ERP.\r\n- Utilisateur : %s\r\n- Période : %s\r\nCliquez ici pour afficher la note de frais: %s.";
$message = ($corps, $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);

我认为这是一个很大的语法错误。除非我误解你的任务。打开php错误并调试脚本:

ini_set('display_errors', true);
error_reporting(E_ALL);