You can use parse_url();
$url = 'http://www.mydomain.com/abc/';
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH);
which would give you
Array
(
[scheme] => http
[host] => www.mydomain.com
[path] => /abc/
)
/abc/
Update: to get current page url and then parse it:
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
print_r(parse_url(curPageURL()));
echo parse_url($url, PHP_URL_PATH);
source for curPageURL function
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…