在PHP电子邮件中的HTML

时间:2011-08-02 22:35:04

标签: php html email

有人可以解释为什么

'。 $结束。 '!

'的工作方式不同。 $敬礼。 '!

在以下代码中?我错过了什么?

                    $salutation = 'Greetings, ' . $cname;
                $ending = 'Thank you for using HammerPins, ' . $cname;

                $subject = 'Hammerpins.net Alert: Newly Added Bowling Tournaments';
                $message = '
                <html>
                <body>
                    <p>' . $salutation . '!</p>
                    <p>New tournaments were added to the HammerPins database this week in the following counties:</p>';
                    foreach ($user_array as $single_user_item) {
                        $message .= "$single_user_item[link]";
                    }'
                    <p>' . $ending . '!</p>
                </body>
                </html>
                ';

感谢您的帮助。

2 个答案:

答案 0 :(得分:3)

因为你在foreach循环之前结束了原始语句。试试这个:

                $salutation = 'Greetings, ' . $cname;
            $ending = 'Thank you for using HammerPins, ' . $cname;

            $subject = 'Hammerpins.net Alert: Newly Added Bowling Tournaments';
            $message = '
            <html>
            <body>
                <p>' . $salutation . '!</p>
                <p>New tournaments were added to the HammerPins database this week in the following counties:</p>';
                foreach ($user_array as $single_user_item) {
                    $message .= "$single_user_item[link]";
                }
                $message .= '<p>' . $ending . '!</p>
            </body>
            </html>
            ';

答案 1 :(得分:1)

你错过了$ message. =在foreach

关闭之后