在PHP生成的电子邮件中放置链接时出错

在PHP生成的电子邮件中放置链接时出错

问题描述:

i am trying to send html text to email using php i write code for only message part below

$message="<html><body> 
<div><b>Title</b>:$app $vesion </div>
<div><a href="http://localhost/download/row[3]">Install Team Provisioning File</a>
</div> <br/>
<div><a href="http://localhost/download/row[5]">install binary</a>
</div>
 <div><b>Released</b>:$date</div> 
<body>
<html>";

but it shows error syntax error, unexpected T_STRING at a href part please suggest me for how append a herf in $message

我正在尝试使用php将html文本发送到电子邮件我只为下面的消息部分编写代码 p> \ n

  $ message =“&lt; html&gt;&lt; body&gt; 
&lt; div&gt;&lt; b&gt; Title&lt; / b&gt ;: $ app $ vesion&lt; / div&gt; 
&lt; div&gt;  &lt; a href =“http:// localhost / download / row [3]”&gt;安装团队配置文件&lt; / a&gt; 
&lt; / div&gt;&lt; br /&gt; 
&lt; div&gt;&lt; a href  =“http:// localhost / download / row [5]”&gt;安装二进制文件&lt; / a&gt; 
&lt; / div&gt; 
&lt; div&gt;&lt; b&gt;已发布&lt; / b&gt ;: $ date&lt; / div&gt  ; 
&lt; body&gt; 
&lt; html&gt;“; 
  code>  pre> 
 
 

但它显示错误语法错误,href部分出现意外的T_STRING 请告诉我如何追加 $ message中的herf p> div>

You need to escape your double-quotes with \"

$message="<html><body> 
<div><b>Title</b>:$app $vesion </div>
<div><a href=\"http://localhost/download/row[3]\">Install Team Provisioning File</a>
</div> <br/>
<div><a href=\"http://localhost/download/row[5]\">install binary</a>
</div>
 <div><b>Released</b>:$date</div> 
<body>
<html>";

Also, is row[3] and row[5] a PHP var? If so, it needs a $ in front.

The internal quotations, in the href=... part are closing the wrapping quotes. Try this:

$message="<html><body> 
<div><b>Title</b>:$app $vesion </div>
<div><a href='http://localhost/download/" . $row[3] . "'>Install Team Provisioning File</a>
</div> <br/>
<div><a href='http://localhost/download/" . $row[5] . "'>install binary</a>
</div>
 <div><b>Released</b>:$date</div> 
<body>
<html>";