0

A partner's payment system is calling a page of mine to confirm transactions. It's sending GET parameters, and one of them is duplicated : same key, different value.

Like this :

?(othersparams)&REFERENCE=test1&REFERENCE=test2

(FYI I have no control on these params)

I only need the first one, and until now it always worked with $_GET['REFERENCE']

Since yesterday we had payment problems, and I saw that this is the second value that is parsed instead of the first.

There was no server change to my knowledge.

Can you tell me more about PHP behaviour when given duplicates GET param keys ? What could explain this change ?

Thanks a lot.

2
  • You cannot rely on environment specific quirks to get this to work. If you want consistent behaviour you will need to parse the query parameters manually using the $_SERVER["QUERY_STRING"] Commented Apr 8, 2016 at 12:04
  • The reason can be wrong script in parther system. However you can avoid this problem by parsing $_SERVER['QUERY_STRING'] which will give you all sent parameters. Commented Apr 8, 2016 at 12:04

1 Answer 1

1

Just as K-Balo said,
The query string gets parsed into the associative array $_GET, so when there are duplicated keys only the last version of the value is present on the map. You can however access the raw $_SERVER['QUERY_STRING'] and parse it on your own.

You can also refer to this post:
Can I have multiple $_GET with the same key, different values?

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

4 Comments

Hope you understood ! (do not hesitate to ask me back)
Until now, only the first version was parsed... It's just since yesterday that the second version is preferred. (php 5.6). I don't understand this change
You can try to change PHP version in your control panel .. That should work
This is the same version for months. Also, there is no panel or automatic updates, we are our own host and have total control over that

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.