简体   繁体   English

如何将当前URL传递到mailto正文

[英]How to pass current URL to mailto body

I have problem with passing url into mail body. 我在将url传递到邮件正文时遇到问题。 I have use this: 我用这个:

<?php
function CurrentPageURL()
{
$pageURL = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
$pageURL .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER
["REQUEST_URI"] : $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
return $pageURL;
}
?>

and mailto:?body=<?php echo CurrentPageURL(); ?> mailto:?body=<?php echo CurrentPageURL(); ?> mailto:?body=<?php echo CurrentPageURL(); ?>

Instead of this link as result: http://www.something.com/index.php?id=03new&new=50&lang=en 结果不是此链接: http : //www.something.com/index.php?id=03new&new=50&lang=zh-CN

I get this one in mail body: http://www.something.com/index.php?id=03new 我在邮件正文中得到了这个: http : //www.something.com/index.php?id=03new

Please help me how to pass all link including "&". 请帮助我如何传递所有链接,包括“&”。

Thx 谢谢

'&' is used in mailto to separate different parts like: 在mailto中使用'&'来分隔不同的部分,例如:

&subject=some_subject&body=message_body

So will be interpreted as an (invalid) parameter for the mailto (and omitted). 因此将被解释为mailto的(无效)参数(并省略)。 So if you want to have '&' (and the rest of url) inside the body, it needs to be replaced with their % value. 因此,如果您想在正文中包含“&”(以及其余的url),则需要将其替换为它们的%值。 Using a function like urlencode() will do the job. 使用urlencode()类的函数即可完成工作。

<?php
function CurrentPageURL()
{
...
return urlencode($pageURL);
}
?>

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

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