The JUri Class can be used to get information about the Joomla URI. This class serves two purposes. First it parses a URI and provides a common interface for the Joomla Platform to access and manipulate a URI. Second it obtains the URI of the current executing script from the server regardless of server.
$uri = JUri::getInstance();
It returns the global JUri object, only creating it if it doesn't already exist.