poe Posted May 13, 2007 Share Posted May 13, 2007 if i go: $homePage = $_SERVER['REQUEST_URI']; i get: home page = /indie/index.php?list=top if i go: $homePage = basename($_SERVER[php_SELF]); i get: home page = index.php what i want is something in the middle: home page = index.php?list=top so it only shows the base script name, but also includes the parameters. thanks chris Quote Link to comment https://forums.phpfreaks.com/topic/51211-_server/ Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 <?php function typedurl() { $homePage = basename($_SERVER["PHP_SELF"]); $homePage .= "?"; foreach($_GET as $k => $v) { $homePage .= "$k=$v&"; } $length = strlen($homePage); $newlen = $length - 1; $homePage = substr($homePage, 0, $newlen); return $homePage; } echo typedurl(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/51211-_server/#findComment-252168 Share on other sites More sharing options...
cmgmyr Posted May 13, 2007 Share Posted May 13, 2007 You could just do something like this: <?php $homePage = $_SERVER['REQUEST_URI']; $homePage= str_replace('/indie/', '', $homePage); echo $homePage; //index.php?list=top ?> Quote Link to comment https://forums.phpfreaks.com/topic/51211-_server/#findComment-252170 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 LOL just thought of a much easier way: <?php function typedurl() { $homePage = $_SERVER['REQUEST_URI']; $bits = explode("/", $homePage); $last = count($bits); $last = $last - 1; $homePage = $bits[$last]; } echo typedurl(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/51211-_server/#findComment-252172 Share on other sites More sharing options...
Wuhtzu Posted May 13, 2007 Share Posted May 13, 2007 _The_ easiest way to do it is like this: $var = basename($_SERVER['PHP_SELF']) . "?" . $_SERVER['QUERY_STRING']; http://no.php.net/reserved.variables Quote Link to comment https://forums.phpfreaks.com/topic/51211-_server/#findComment-252182 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.