Home >Backend Development >PHP Tutorial >php Get $_SERVER[REQUEST_URI] value_PHP tutorial

php Get $_SERVER[REQUEST_URI] value_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:55:171056browse

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.html
TechArticle
Among 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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn