繁体   English   中英

将功能结果添加到我的HTML电子邮件php中

[英]Adding function result to my html email php

我敢肯定这真的很简单,但是让我发疯了!

<p>'.printHistory($result).' </p>

上面是我的html电子邮件中的代码片段,这是函数printHistory

function printHistory($result){
    $hisNum=0;
    foreach ($result as $item){
        "<b><u>update Number </u></b>".$hisNum."<br/>";
        "<b>Time: </b>". $item['start_time']."<br/>";
        "<b>Date: </b>". $item['date']."<br/>";
        "<b>Comment: </b>". $item['comment']."<br/>";
        $hisNum=$hisNum+1;
    }
}

我没有收到任何错误,但是文本没有打印到我的电子邮件中。 任何帮助,将不胜感激!

您忘记return字符串,因此不会产生任何输出。

function printHistory($result){
    $hisNum=0;
    $string = "";
    foreach ($result as $item){
       $string .= "<b><u>update Number </u></b>".$hisNum."<br/>";
       $string .= "<b>Time: </b>". $item['start_time']."<br/>";
       $string .= "<b>Date: </b>". $item['date']."<br/>";
       $string .= "<b>Comment: </b>". $item['comment']."<br/>";
       $hisNum=$hisNum+1;
    }
    return $string;
}

您需要回显结果:

function printHistory($result){
        $hisNum=0;
        foreach ($result as $item){
          echo "<b><u>update Number </u></b>".$hisNum."<br/>" 
              . "<b>Time: </b>". $item['start_time']."<br/>"
              . "<b>Date: </b>". $item['date']."<br/>"
              . "<b>Comment: </b>". $item['comment']."<br/>";
          $hisNum=$hisNum+1;
        }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM