$MM_removeList = "&index=";
if ($MM_paramName != "") $MM_removeList .= "&".strtolower($MM_paramName)."=";
$MM_keepURL="";
$MM_keepForm="";
$MM_keepBoth="";
$MM_keepNone="";
// add the URL parameters to the MM_keepURL string
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepURL .= "&".$key."=".urlencode($val);
}
}
// add the URL parameters to the MM_keepURL string
if(isset($HTTP_POST_VARS)){
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepForm .= "&".$key."=".urlencode($val);
}
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
$MM_keepBoth = $MM_keepURL."&".$MM_keepForm;
if (strlen($MM_keepBoth) > 0) $MM_keepBoth = substr($MM_keepBoth, 1);
if (strlen($MM_keepURL) > 0) $MM_keepURL = substr($MM_keepURL, 1);
if (strlen($MM_keepForm) > 0) $MM_keepForm = substr($MM_keepForm, 1);
高手请详细讲解此段代码.

解决方案 »

  1.   

    这段代码主要作用拼接一个url字符串  然后是哪种方式传递(POST还是GET)然后解析 
    $HTTP_GET_VARS是以前版本的$_GET
    $HTTP_POST_VARS是以前版本的$_POST$MM_removeList = "&index=";
    if ($MM_paramName != "") $MM_removeList .= "&".strtolower($MM_paramName)."=";
    $MM_keepURL="";
    $MM_keepForm="";
    $MM_keepBoth="";
    $MM_keepNone="";
    // add the URL parameters to the MM_keepURL string
    reset ($HTTP_GET_VARS);//将数组的内部指针指向第一个单元 
    while (list ($key, $val) = each ($HTTP_GET_VARS)) {//数组赋值 详细看list函数
    $nextItem = "&".strtolower($key)."=";
    if (!stristr($MM_removeList, $nextItem)) {//判断$MM_removeList中有没有$nextItem
    $MM_keepURL .= "&".$key."=".urlencode($val);//urlencode编码 针对中文传递问题
    }
    }
    // add the URL parameters to the MM_keepURL string
    if(isset($HTTP_POST_VARS)){//判断$_POST值
    reset ($HTTP_POST_VARS);//重置 同上一个reset
    while (list ($key, $val) = each ($HTTP_POST_VARS)) {//再赋值
    $nextItem = "&".strtolower($key)."=";//strtolower转换小写
    if (!stristr($MM_removeList, $nextItem)) {//和$_GET部分相同
    $MM_keepForm .= "&".$key."=".urlencode($val);
    }
    }
    }
    // create the Form + URL string and remove the intial '&' from each of the strings
    $MM_keepBoth = $MM_keepURL."&".$MM_keepForm;
    if (strlen($MM_keepBoth) > 0) $MM_keepBoth = substr($MM_keepBoth, 1);//判断长度后 截取全长度字符串
    if (strlen($MM_keepURL) > 0) $MM_keepURL = substr($MM_keepURL, 1);
    if (strlen($MM_keepForm) > 0) $MM_keepForm = substr($MM_keepForm, 1);
      

  2.   

    很老的代码了。现在都用$_SERVER
      

  3.   

    现在都用  $_SERVER 了 
    不过楼主 的精神 值得学习 
    不仅要知其然 ,还要知其所以然。 
    很好 。。
    真是 后生可畏啊     呵呵