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 string reset ($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 string if(isset($HTTP_POST_VARS)){ //$HTTP_POST_VARS同$HTTP_GET_VARS reset ($HTTP_POST_VARS); //重置$HTTP_POST_VARS,使其指针回到0 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); //如果$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>

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor
