php获取当前url

在 apache环境下可以直接使用  $_SERVER['REQUEST_URI']

但咋IIS环境下不起作用

在IIs环境下

   function request_uri(){
if (isset($_SERVER['argv']))
{
$uri = $_SERVER['PHP_SELF'] .(empty($_SERVER['argv'])?'':('?'. $_SERVER['argv'][0]));
}
else
{
$uri = $_SERVER['PHP_SELF'] .(empty($_SERVER['QUERY_STRING'])?'':('?'. $_SERVER['QUERY_STRING']));
}
return $_SERVER['REQUEST_URI'] = $uri;
}

你可能感兴趣的:(php编程)