Give this a try:
<?php
$location = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1);
print($location);
?>
For example: If $_SERVER['REQUEST_URI'] is /test/test.php it will search for the last / and take everything off after that. So the result would be /test/ Does that work for ya?
[edit] BTW, if you want it to print test/ instead of /test/ change the 0 befor strrpos to 1. [/edit]