This URL.php class may be a good start (not sure if it is "widely" accepted, though).
URL class for http and https schemes
This class allows you to store absolute or relative URLs and get different parts to them (scheme, host, port, part, request, fragment).
It will also accept and try to resolve the relative URL with the absolute URL already stored.
Note. This URL class is based on an HTTP scheme.
Example:
$url =& new URL('http://www.domain.com/path/file.php?query=blah'); echo $url->get_scheme(),"\n"; // http echo $url->get_host(),"\n"; // www.domain.com echo $url->get_path(),"\n"; // /path/file.php echo $url->get_query(),"\n"; // query=blah // Setting a relative URL against our existing URL $url->set_relative('../great.php'); echo $url->as_string(); // http://www.domain.com/great.php
source share