When youAfter initially answering this question by saying there should be no reason to modify superglobals such as $_POST, you are tamperingI'm editing this answer with an example of a time when I've decided to.
I'm currently working on a URL rewrite database table whereby the original datarequest column directs the user submittedto its corresponding target column.
This data is important. For instance, you can keep a log of everything your users have ever submittedrequest might be blog/title-here and see where they sometimes are going wrongits target might be blog.php?id=1.
Ultimately, there isSince no reason to modify superglobals when you see how easy itblog.php is expecting $_GET variables, and I don't want to simply create an array based on whatchange the user has submitted. For instance:
$post = $_POST;
This creates a new array that you can tamper with to your heart's content. It looks nicer too:
echo $_POST["surname"];
// is the same as:
echo $post["surname"];
Alsoheader("Location:"), I'm not a fan of creating a new variable for every bit of information the user has sent. Arrays are much easier to work with - even simply trimming the valuesleft doing something like this:
//$uri Why have this:
$username = trimexplode($username);
$firstname ='?', trim($firstname$uri_request);[0];
$surname$params = trim($surname);
// When you can have this instead:
array_walk_recursiveexplode($post'?', function (&$val$uri_request) { [1];
$val = trimparse_str($val);$params,
}$_GET);
This creates a $_GET array containing the intended parameters passed by the target column.
Ultimately, I would strongly advise against modifying superglobals unless you absolutely have to.