PHP algorithm can not understand, please master step by step to explain it! What to do with it

Source: Internet
Author: User
PHP algorithm can not understand, please master step by step to explain it! Quick Rush
$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);

------Solution--------------------
The get parameters and post parameters are all stitched together into the get parameters, forming a URL called Mm_keepboth, due to splicing when taken. &key=val, so the string starts to have a &amp, and needs to be substr deleted.

------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 Parame Ters which should not be maintained$mm_removelist = "&index="; if ($MM _paramname! = "") $MM _removelist. = "&". Strto Lower ($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. The early PHP3/4 versions were all $http_get_vars, but later versions $http_get_vars were deprecated. Instead of $_get. while (list ($key, $val) = every ($HTTP _get_vars)) {//Iterate through the array for each item, key = $key, value = $val $nextitem = "&". Strtolower ($key). " = "if (!stristr ($MM _removelist, $nextItem)) {//If $nextitem$mm_keepurl is not present in mm_removelist. =" & ". $key."  = ". UrlEncode ($val); Connection string}}//Add the URL parameters to the Mm_keepurl stringif (isset ($HTTP _post_vars)) {//$HTTP _post_vars with $http_get_  Varsreset ($HTTP _post_vars); Reset $http_post_vars so that its pointer goes back to 0while (list ($key, $val) = each ($HTTP _post_vars)) {//traversal, IBID. $nExtitem = "&". Strtolower ($key). "    ="; The connection string if (!stristr ($MM _removelist, $nextItem)) {//Ibid. $mm_keepform. = "&". $key. "  = ". UrlEncode ($val); Ditto}}}//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 $mm_keepboth byte length is greater than 0, then intercept from the 1-byte position to the end if (strlen ($MM _keepurl) > 0) $MM _keepurl = substr ($MM _keepurl, 1);   Similar to the IF (strlen ($MM _keepform) > 0) $MM _keepform = substr ($MM _keepform, 1);  Like 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.