Ec (2); the Code is as follows: Get the current Script URL functionGetCurUrl () {if (! Empty ($ _ SERVER [& quot; REQUEST_URI & quot;]) {$ scriptName $ _ SERVER [& quot; REQUEST_URI & quot;]; $ nowurl $ scriptName ;} else {$ scriptNa script ec (2); script
The Code is as follows:
// Obtain the current Script URL
Function GetCurUrl ()
{
If (! Empty ($ _ SERVER ["REQUEST_URI"])
{
$ ScriptName = $ _ SERVER ["REQUEST_URI"];
$ Nowurl = $ scriptName;
}
Else
{
$ ScriptName = $ _ SERVER ["PHP_SELF"];
If (empty ($ _ SERVER ["QUERY_STRING"])
{
$ Nowurl = $ scriptName;
}
Else
{
$ Nowurl = $ scriptName ."? ". $ _ SERVER [" QUERY_STRING "];
}
}
Return $ nowurl;
}
The other is to replace the value of a variable in the query part of the PHP website. For example, we need to set key = 321 in $ url;
In fact, there are several situations:
$ Url = 'www .111cn.net/a.php tutorial? Key = 330 ′;
Or $ url = 'www .111cn.net/a.php;
Or $ url = 'www .111cn.net/a.php? Cat = 2 ′;
And so on. Although there are many situations, PHP is very simple to handle, as shown below:
The Code is as follows:
/* Set a parameter in the URL to a value * // [This paragraph is quite good]
Function url_set_value ($ url, $ key, $ value)
{
$ A = explode ('? ', $ Url );
$ Url_f = $ a [0];
$ Query = $ a [1];
Parse_str ($ query, $ arr );
$ Arr [$ key] = $ value;
Return $ url_f .'? '. Http_build_query ($ arr );
}
However, my replacement is written in this way .. Of course ..
Homepage 1 2 3 4 last