Among the many predefined server variables in PHP, $_SERVER["REQUEST_URI"] is frequently used, but this variable is only supported by apache. Therefore, we need a more general way to obtain the value of REQUEST_URI.
The code is as follows
代码如下 |
复制代码 |
function request_uri()
{
if (isset($_SERVER['REQUEST_URI']))
{
$uri = $_SERVER['REQUEST_URI'];
}
else
{
if (isset($_SERVER['argv']))
{
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
}
else
{
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
}
}
return $uri;
}
?>
|
|
Copy code |
|
function request_uri()
{
If (isset($_SERVER['REQUEST_URI']))
{
$uri = $_SERVER['REQUEST_URI'];
}
else
{
If (isset($_SERVER['argv']))
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
else
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
}
Return $uri;
}
?>
http://www.bkjia.com/PHPjc/632250.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/632250.htmlAmong the many predefined server variables in PHP, $_SERVER[REQUEST_URI] is often used, but this variable only Apache only supports it, so we need a more general way...