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

php Get $_SERVER[REQUEST_URI] value_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:55:17
Original
1120 people have browsed it

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 of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template