2011-08-02 37 views
0

有人可以請解釋爲什麼html內的PHP電子郵件

'。 $結束。 「!

不同。 $稱呼。 「!

在下面的代碼?我錯過了什麼?

    $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> 
       '; 

感謝您的幫助。

回答

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> 
      '; 
+0

我不相信!真的認爲我已經嘗試過,但不要猜測。非常感謝你的幫助! –

1

你錯過了$消息=後關閉}在foreach的