Sometimes we need to retain GET and POST parameters to pass on the next page or other purposes! For example, originally
It’s convenient for work, so I wrote this code!
Hope everyone can communicate more!
/*
Programming: Lin Jianxuan (Piaofeng Design Studio)
made in Zhuhai by 2007-03-24
QQ: 5818500
Email: linzhenxuan@163 .com
Do not delete this copyright information
Purpose: retain and modify GET and POST parameters
*/
function getplus($x=,$value=,$plus=close,$method= all){
Global $_GET,$_POST;
$array = array();
if($method==all){
$array[] = $_GET;$array[] = $_POST;}
elseif($method==get){$array[] = $_GET;}
elseif($method==post){$array[] = $_POST;}
$a = $_GET;
$i = 1;
$true = 0;
foreach($array as $k => $a){
foreach($a as $b = > $c){
if($b==$x){
$c = $value;
$true = 1;//Found it
$true2 = 1;
}
if($plus==close){
if($i==1){
$temp .= "?$b=$c";
}else{
$temp .= "&$b=$c";
}
}else{
if($i==1){
if($true2!=1){$temp .= "?$b=$c";}else{$temp.="?";unset($true2);}
}else{
if($true2!=1){$temp . = "&$b=$c";}else{unset($true2);}
}
}
$i++;
}
}
if($true= =0){
if (strpos($temp,"?")>0 || strpos($temp,"=")>0){
$temp .= "&$x=$ value";
}else{
$temp .= "?$x=$value";
}
}
elseif($true==1 && $plus!=close) {
if (strpos($temp,"?")>0 || strpos($temp,"=")>0){
$temp .= "&$x=$value";
}else{
$temp .= "?$x=$value";
}
}
return $temp;
}
?>
GET: ?method=1&a=1&b=2
POST: y=2007&m=03
Used
=getplus(c,3)?>
It will be displayed after
?method=1&a=1&b=2&y=2007&m=03&c=3
After using
=getplus(a,3,open)?> 🎜>?method=1&b=2&y=2007&m=03&a=3
Drag a=3 to the end
I use =getplus(a,,open)?> to combine it with javascript
Previous page
I still feel pretty good!
Maybe there are still bugs that haven’t been discovered yet!
I hope everyone will mention it more!
http://www.bkjia.com/PHPjc/508239.html