php: How to resubmit (and add to) original $_REQUEST variables
jp.php?q=dog
or jp.php?h=123&f=14
etc. Is there a better way to resubmit the arguments (other than looping through q,h,f,...) and eg add '&action=update'?
This is an attempted looped version:
$req_str="";
foreach($_REQUEST as $req_k => $req_v){
$req_str.=$req_k."=".$req_v."&";
}
echo "<a href=jp.php?".$req_str."&action=update >UPDATE</a>";
UPDATE
I think $_SERVER['QUERY_STRING']
is what I was looki开发者_开发问答ng for.
echo "<a href=jp.php?".$_SERVER['QUERY_STRING']."&action=update >UPDATE</a>";
Not sure though, whether this would work if variables were submitted via 'POST' rather than 'GET'?
$query = http_build_query(array_merge($_GET, array('action' => 'update')));
printf('<a href="jp.php?%s">Update</a>', $query);
精彩评论