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.

FLX
  • 2,626
  • 4
  • 26
  • 57
  • 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"]` – apokryfos Apr 08 '16 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. – mitkosoft Apr 08 '16 at 12:04

1 Answers1

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?

Tilak Madichetti
  • 4,110
  • 5
  • 34
  • 52