格式化 mailto link 以便 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);

输出为:

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