繁体   English   中英

格式化 mailto 链接,以便 PHP 可以清楚地解释它

[英]Format mailto link so that PHP can cleanly interpret it

如何格式化mailto:协议,以便 PHP 可以按以下方式解释它:

//General PHP test:
print_r($_GET);

//Desired output:
Array
(
 [mailto] => me@example.com
 [subject] => Test Subject
 [body] => Placeholder body example.
 [bcc] => you@example.com
 [cc] => them@example.com
)

目前我有mailto:test@example.com&subject=The%20Subject&body=Some+test+text. 虽然它被解释为:

Array
(
 [mailto:test@example_com&subject=The%20Subject&body=Some+test+text_] => 
)

如果您愿意对输入字符串进行小幅更改,而不是mailto:from@example.com ,您愿意使用等号,例如mailto=from@example.com ,然后以下代码可以轻松完成:

$querystr = "mailto=test@example.com&subject=The%20Subject&body=Some+test+text";
$array = array();

parse_str($querystr, $array);

print_r($array);

output 是:

Array ( [mailto] => test@example.com [subject] => The Subject [body] => Some test text )

暂无
暂无

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

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