如何在使用PHP编码的mailto链接中添加换行符';s rawurlencode
我有这样的东西如何在使用PHP编码的mailto链接中添加换行符';s rawurlencode,php,html,Php,Html,我有这样的东西 <a href='mailto:mike@example.com?subject=<?php print rawurlencode('This is the subject.');?>&body=<?php print rawurlencode('Line 1 of body. Line 2 of body.');?>'>Email</a> 我想在邮件正文中加一个换行符。我通过谷歌发现,您可以将%0D%0A放入mail
<a href='mailto:mike@example.com?subject=<?php print rawurlencode('This is the subject.');?>&body=<?php print rawurlencode('Line 1 of body. Line 2 of body.');?>'>Email</a>
我想在邮件正文中加一个换行符。我通过谷歌发现,您可以将%0D%0A放入mailto中进行换行,但问题是rawurlencode将只对其进行编码。为了在消息中显示换行符,我可以在rawurlencode中添加什么内容。
\n
-这称为换行符-特殊字符如果使用双引号,可以在字符串中添加\r\n
字符,这将避免您描述的双引号问题
<?php
echo rawurlencode("Line One.\r\nLine Two.");
/* Line%20One.%0D%0ALine%20Two. */
@cody gray,是我试图指出\r\n
是Windows特有的。再次尝试,希望这次成功:)似乎没有\r和/或\n的组合起作用。它们只是在消息正文中显示为\r和\n
<?php
$params = array(
'subject' => 'Subject',
'body' => "Line One.\r\nLine Two."
);
echo http_build_query($params);
/* subject=Subject&body=Line+One.%0D%0ALine+Two. */