Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


php_tricks

This is an old revision of the document!


# the entire URL of the current page, including query string
$url = $_SERVER['REQUEST_URI'];

# the base URL of the current page without query string
$url_base = $_SERVER['PHP_SELF'];

# The web host
$host = $_SERVER['HTTP_HOST'];

# Just the path of the URL without the filename
$path = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1);

More info on parsing the URL: http://php.net/manual/en/function.parse-url.php

php_tricks.1445740411.txt.gz · Last modified: 2015/10/24 22:33 by juckins