| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
A simple though strict (and cleanly coded) version of the native function though without the pointless string replacement of periods with underscores:
<?php
function parse_query_string_mailto()
{//2025-09-11; Used in place of PHP's native parse_str() which pointlessly replaces periods with underscores:
$r = false;
$qs = ((isset($_SERVER['QUERY_STRING'])) ? urldecode($_SERVER['QUERY_STRING']) : false);
if ($qs && strpos($qs, 'mailto:'))
{
$s = explode('mailto:', $qs, 2);
if (count($s) == 2)
{
$r = array();
$pairs = explode('&', $s[1]);
foreach ($pairs as $pair)
{
$p = explode('=', $pair, 2);
$r[$p[0]] = urldecode($p[1]);
}
}
}
return $r;
}
?>
Example relative URL:
mail/compose/?mailto%3Asubject%3DTest%2520Subject%26body%3DHello%2520World!%26from%3Duser%40example.com
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.84.18 (proxied: 45.134.140.56)
----
Manual Page -- https://php.net/manual/en/function.parse-str.php
Edit -- https://main.php.net/note/edit/130479
Del: integrated -- https://main.php.net/note/delete/130479/integrated
Del: useless -- https://main.php.net/note/delete/130479/useless
Del: bad code -- https://main.php.net/note/delete/130479/bad+code
Del: spam -- https://main.php.net/note/delete/130479/spam
Del: non-english -- https://main.php.net/note/delete/130479/non-english
Del: in docs -- https://main.php.net/note/delete/130479/in+docs
Del: other reasons-- https://main.php.net/note/delete/130479
Reject -- https://main.php.net/note/reject/130479
Search -- https://main.php.net/manage/user-notes.php