ShootingBlanks Posted September 11, 2007 Share Posted September 11, 2007 I am drawing a blank on the PHP code that pulls the end of a URL (after the final slash)... So, in: http://www.thesite.com/subfolder1/sitepage.php?pageID=1234 I would want to get: sitepage.php?pageID=1234 I know that $_SERVER['QUERY_STRING'] would get me everything after the "?", but I need a little before that too. I tried searching the PHP manual, but obviously my search terms weren't pulling up what I needed. Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/ Share on other sites More sharing options...
pocobueno1388 Posted September 11, 2007 Share Posted September 11, 2007 Put this code on that page: echo '<pre>'; print_r($_SERVER); echo '</pre>'; That will make a list of $_SEVER variables and what they would print out if you used them. Just search the list for the URL you are looking for, then it will tell you what variable to use. Quote Link to comment https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/#findComment-346068 Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2007 Share Posted September 11, 2007 Predefined variables: http://us2.php.net/reserved.variables The answer is probably REQUEST_URI. Quote Link to comment https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/#findComment-346069 Share on other sites More sharing options...
ShootingBlanks Posted September 11, 2007 Author Share Posted September 11, 2007 The answer is probably REQUEST_URI. Yes, that is it - but not as it is. Can you help me with some modification, please? Here's what I need... [REQUEST_URI] would get me something with a long prefix that always ends with "/admin/" before what I am actually trying to capture. I need everything after the /admin/. Is there any kind of PHP code that could be written to pull out everything after the string of text "/admin/" within the $_SERVER [REQUEST_URI] variable??? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/#findComment-346078 Share on other sites More sharing options...
ShootingBlanks Posted September 11, 2007 Author Share Posted September 11, 2007 FIGURED IT OUT!... The solution is: substr(strstr($_SERVER['REQUEST_URI'], '/admin/'),7); Thanks for everyone who got me on the road to my answer... Quote Link to comment https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/#findComment-346114 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.