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 Link to comment https://forums.phpfreaks.com/topic/24938-using-the-request_uri-statement/ 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.... Link to comment https://forums.phpfreaks.com/topic/24938-using-the-request_uri-statement/#findComment-113639 Share on other sites More sharing options...
Jenk Posted October 24, 2006 Share Posted October 24, 2006 alternatively..[code]<?phpecho $_SERVER['SCRIPT_NAME'];?>[/code] Link to comment https://forums.phpfreaks.com/topic/24938-using-the-request_uri-statement/#findComment-113641 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. Link to comment https://forums.phpfreaks.com/topic/24938-using-the-request_uri-statement/#findComment-113669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.