php to check which url is requested
I want to know which url is requested,
like test.com/bla.php or test.com/web.php so that I see bla.php and web.php
This is what I use at the moment, but is it safe?
Thanks in common,
$file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
Could you just use:
$pfile = basename($_SERVER['SCRIPT_NAME']);
I can't think why it would not be.
Originally Posted by DavidBonting
You may want to use REQUEST_ADDR instead:
That'll give you the URL, as opposed to the script being executed (the two won't always be the same).
Thanks, but that's not what I'm looking for. The above (you) method works fine
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread