119

requesturi

request_uri
SYNOPSIS

request_uri()

DESCRIPTION

request_uri returns the request URI beginning with a / (SLASH), including the query string if present.

If the web server does not provide $_SERVER['REQUEST_URI'], request_uri reconstructs it from the available server variables.

CODE
  1. function request_uri() {
  2.     if (isset($_SERVER['REQUEST_URI'])) {
  3.         $uri = $_SERVER['REQUEST_URI'];
  4.     }
  5.     else {
  6.         if (isset($_SERVER['argv'])) {
  7.             $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['argv'][0];
  8.         }
  9.         else if (isset($_SERVER['QUERY_STRING'])) {
  10.             $uri = $_SERVER['SCRIPT_NAME'];
  11.  
  12.             if (!empty($_SERVER['QUERY_STRING'])) {
  13.                 $uri .= '?' . $_SERVER['QUERY_STRING'];
  14.             }
  15.         }
  16.         else {
  17.             $uri = $_SERVER['SCRIPT_NAME'];
  18.         }
  19.     }
  20.  
  21.     $uri = '/'. ltrim($uri, '/');
  22.  
  23.     return $uri;
  24. }
SEE ALSO

engine

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].