> 백엔드 개발 > PHP 튜토리얼 > php算法看不懂,请高手逐句给解释下吧!该怎么处理

php算法看不懂,请高手逐句给解释下吧!该怎么处理

WBOY
풀어 주다: 2016-06-13 10:19:43
원래의
1060명이 탐색했습니다.

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);   //类似上面<div class="clear">
                 
              
              
        
            </div>
로그인 후 복사
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿