Jump to content

[SOLVED] Quick easy code question...


ShootingBlanks

Recommended Posts

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!!!

 

 

Link to comment
https://forums.phpfreaks.com/topic/68851-solved-quick-easy-code-question/
Share on other sites

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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.