So just a quick thought and I understand that there are millions of ways around this ‘problem’ but I was wondering if there is a character or format for both initiating and separating GET parameters. Let me explain:
I am redirecting the user to a link defined as a variable but adding on a parameter at the end like so:
Header("Location: ".$link."&err=1");
The problem is, some of these links ($link) will contain GET params and some will not. If the link does not already contain GET parameters, ‘&’ will not work as an initiator.
Header("Location: page&err=1");
And if the link does already contain parameters, ‘?’ will not work as a separating character.
Header("Location: page?val=123?err=1");
So again, I know there are many ways around this and I’m not lookign for someone to code a simple check for me but I’m curious about the link formatting aspect and I can’t find anything through my own research. I’m honestly expecting that the answer is ‘not possible’ but I’m intrigued enough to ask now, thanks.
2
Answers
No.
?
starts the query string.&
and;
separate key=value pairs in application/x-www-form-urlencoded data which is the format most back ends expect. (;
hasn’t got as good a level of support).Will parse_url() not work?
Specifically
parse_url($url, PHP_URL_QUERY);
http_build_query() could also be useful