mkosmosports Posted October 24, 2006 Share Posted October 24, 2006 I have the following variable defintition : $currentt = $_SERVER['REQUEST_URI'];echoing this gives me the current URL that is being used. However, I would like to get it to only show the name of the html page that is being used.For example, currently if the url is "http://localhost/index.htm?g=2&h=4", and I echo $currentt I want it only to return "index.htm" not the entire url...Does anyone know of a way that this can be done?Thanks.mkosmosports Quote Link to comment Share on other sites More sharing options...
mkosmosports Posted October 24, 2006 Author Share Posted October 24, 2006 Nevermind, the below script is working for me... :D $full_path = getenv("REQUEST_URI"); //retrieves the full url $pagename = basename($full_path); //retrieves the name of the html page youre using (with or without any url parameters).... $currentt = substr($pagename //makes sure only the html page name getx extracted... , strrpos($pagename, "/") , strpos($pagename, ".html"));The above variable $currentt will extract the name of the current html page thats being used and nothing but.... Quote Link to comment Share on other sites More sharing options...
Jenk Posted October 24, 2006 Share Posted October 24, 2006 alternatively..[code]<?phpecho $_SERVER['SCRIPT_NAME'];?>[/code] Quote Link to comment Share on other sites More sharing options...
mkosmosports Posted October 24, 2006 Author Share Posted October 24, 2006 I knew there was something simpler around..... :P Thanks Jenk. I will use your alternative solution. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.