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 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(); ?> 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 ?> 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(); ?> 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 Link to comment https://forums.phpfreaks.com/topic/51211-_server/#findComment-252182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.