$PHP_SELF is only the name of the file (itself).
if you want to get the full url, which user has entered, then do $REQUEST_URI
where $REQUEST_URI will be the complete URL EXCEPT your root domain name.
e.g.
http://www.mysite.com/dir1/dir3/index.php
in this case, the $REQUEST_URI will return:
/dir1/dir2/index.php
of course you can get the complete URL, by prefexing every request uri with your site's domain name.
finally, you get all the directory pieces from the url by doing explode(); e.g.
$URL = explode('/', $REQUEST_URI);
$URL[0] // returns dir1
$URL[1] // returns dir2
$URL[2] // returns index.php3
also you can find the number of pieces by:
count($URL);
good luck,
🙂
Daarius...