代码如下:
//获得当前的脚本网址
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;
}
另一个是PHP替换网址中query部分的某变量的值比如 ,我们要设$url中的key=321;
其实有几种情况:
$url='www.111cn.net/a.php教程?key=330′;
或$url='www.111cn.net/a.php;
或$url='www.111cn.net/a.php?cat=2′;
等等。虽然情况很多,但PHP处理起来非常简单,如下:
复制代码 代码如下:
/* 将URL中的某参数设为某值*/ //【这一段就挺好啊】
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);
}
不过我的替换是这样写的。。当然也很烂 。。

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

Zend Studio 13.0.1
Powerful PHP integrated development environment