Php Algorithms cannot be understood. please explain them one by one! What should I do?

Source: Internet
Author: User
Php Algorithms cannot be understood. please explain them one by one! Urgent $ MM_paramName & quot ;;? * ** GoToRecordandMoveToRecord: createstringsformaintainingURLandFormparameterscreatethelistofparameter php algorithm cannot be understood. please explain it one by one! Urgent
$ MM_paramName = "";?

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

------ Solution --------------------
Concatenate the GET and POST parameters into the GET parameters to form a URL called MM_keepBoth. & key = val, so one more string starts &, and must be deleted by substr.

------ Solution --------------------
Let's try it.
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 shocould 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 is equivalent to $ _ GET. In early versions of php3/4, $ HTTP_GET_VARS was used, but later versions of $ HTTP_GET_VARS were discarded. Use $ _ GET instead. While (list ($ key, $ val) = each ($ HTTP_GET_VARS) {// traverse each item in the array, key = $ key, value = $ val $ nextItem = "&". strtolower ($ key ). "="; if (! Stristr ($ MM_removeList, $ nextItem) {// If MM_removeList does not exist $ nextItem $ MM_keepURL. = "&". $ key. "= ". urlencode ($ val); // connection string} // add the URL parameters to the MM_keepURL stringif (isset ($ HTTP_POST_VARS )) {// $ HTTP_POST_VARS is the same as $ HTTP_GET_VARSreset ($ HTTP_POST_VARS); // reset $ HTTP_POST_VARS to return its pointer to 0 while (list ($ key, $ val) = each ($ HTTP_POST_VARS) {// traversal, same as $ nextItem = "&". strtolower ($ key ). "="; // connection string if (! Stristr ($ MM_removeList, $ nextItem) {// same as $ MM_keepForm. = "&". $ key. "= ". urlencode ($ val); // same as above} // 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 the length of $ MM_keepBoth is greater than 0, truncate from 1 byte to the end if (strlen ($ MM_keepURL)> 0) $ MM_keepURL = substr ($ MM_keepURL, 1 ); // similar to above if (strlen ($ MM_keepForm)> 0) $ MM_keepForm = substr ($ MM_keepForm, 1); // similar to above

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.