php演算法看不懂,請高手逐句給解釋下吧!該怎麼處理

來源:互聯網
上載者:User
php演算法看不懂,請高手逐句給解釋下吧!急急
$MM_paramName = "";?

// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
$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);

------解決方案--------------------
把GET參數和POST參數重新全部拼接到GET參數裡,形成一個URL叫做MM_keepBoth,由於拼接時採取了. &key=val,所以字串開始多了一個&, 需要substr刪掉。

------解決方案--------------------
來試試看。
PHP code
 $MM_paramName = ""; // *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters// create the list of parameters which should not be maintained$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 stringreset ($HTTP_GET_VARS);   //$HTTP_GET_VARS等價於$_GET。早起的php3/4版本都是用$HTTP_GET_VARS,不過到了後來版本$HTTP_GET_VARS被棄用了。改用$_GET 了。while (list ($key, $val) = each ($HTTP_GET_VARS)) {   //遍曆數組每項,鍵=$key,值=$val$nextItem = "&".strtolower($key)."=";if (!stristr($MM_removeList, $nextItem)) {   //如果MM_removeList中不存在$nextItem$MM_keepURL .= "&".$key."=".urlencode($val);  //連接字串}}// add the URL parameters to the MM_keepURL stringif(isset($HTTP_POST_VARS)){  //$HTTP_POST_VARS同$HTTP_GET_VARSreset ($HTTP_POST_VARS);  //重設$HTTP_POST_VARS,使其指標回到0while (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);   //如果$MM_keepBoth位元組長度大於0,則從1位元組位置截取到末尾if (strlen($MM_keepURL) > 0) $MM_keepURL = substr($MM_keepURL, 1);    //類似上面if (strlen($MM_keepForm) > 0) $MM_keepForm = substr($MM_keepForm, 1);   //類似上面
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.