2

I need to let my users type anything at the end of my url, like this:

http://mysite.com/?somethingorother

or

http://mysite.com/somethingorother

And then I would like to get that last bit that they added to the end of the url like so:

$var = $_POST[''];

But I'm not sure how to go about this, and I can't find anything, because I'm not quite sure how to search for it.

Any help is appreciated, thanks!

2
  • You might want to consider using $_GET. Commented Dec 30, 2010 at 17:51
  • Okay, but how exactly would I accomplish this, when I don't know what the user has entered? Commented Dec 30, 2010 at 17:53

2 Answers 2

1

With http://mysite.com/?somethingorother you can use:

substr($_SERVER['REQUEST_URI'],2);
Sign up to request clarification or add additional context in comments.

1 Comment

+1 - I will mark as answer when it lets me. Thanks for your help! Btw: I had to change it from 2, to 11 ;)
1

For your second example you'd need to use url rewriting (search mod_rewrite) anyway. If there is a ? you can just

foreach($_GET as $key => $value) {   echo "$key: $value"; }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.