0

What happens if a URL link is like this

http://abc.com/123.php?p=1?source=yahoo&key=56

can 123.php retrieve all parameters?

4
  • After the first question mark, any other question mark is interpreted as "normal" character. Commented Aug 10, 2011 at 13:17
  • @phil I would think its been down voted because it is a simple matter for the OP to check this himself, hence it "does not show any research effort". That's why I down voted it anyway. -1 Commented Aug 10, 2011 at 13:45
  • @vascoshite which is perfectly understandable; just tell him that. Commented Aug 10, 2011 at 13:49
  • Meh, I upvoted. A 10 second google search for the answer is faster than a 5-10 minute research session (depending on your configuration/server set up). These little 5-10 minute tests could add up to hours of lost productivity. Commented Dec 4, 2012 at 17:59

5 Answers 5

2

In PHP $_GET will hold the following ( result of var_dump($_GET) )

array(2) { ["p"]=> string(14) "1?source=yahoo" ["key"]=> string(2) "56" }

If you want to use the question mark (or other reserved chars) use urlencode

Sign up to request clarification or add additional context in comments.

Comments

0

p will gone, you should do

$url = 'http://abc.com/123.php?'.urlencode('p=1?source=yahoo&key=56');

Comments

0

No. I don't think that's a valid query string.

Comments

0

Test it yourself with:

print_r($_GET);

I tested it an I get:

Array ( [p] => 1?source=yahoo [key] => 56 )

If you have control over the string appended to the url use urlencode.

Comments

0

From the RFC 1738 - Uniform Resource Locators (URL):

only alphanumerics, the special characters $-_.+!*'(),, and reserved characters used for their reserved purposes may be used unencoded within a URL.

The character ? is a reserved character. Since the URL you give is not using it for its reserved purpose (separating the "path" from the "searchpart"), the URL is illegal, and you shouldn't rely on any particular behaviour.

Encode the ? character, and ensure that the URL is legal if you want predictable behaviour.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.