URL Multiple Query Parameters Encoded with HTML Entities
Posted
by BRADINO
on Bradino
See other posts from Bradino
or by BRADINO
Published on Fri, 11 Sep 2009 21:10:01 +0000
Indexed on
2010/03/23
5:22 UTC
Read the original article
Hit count: 747
php
I came across a situation where a URL with multiple query parameters was encoded using htmlentities() and PHP was not recognizing the query parameters using $_GET. A common case for encoding urls using htmlentities() is to use them inside XML documents.
So a url with multiple query parameters, encoded using htmlentities() would look like this:
http://www.bradino.com/?color=white&size=medium&quantity=3
and when that url is accessed the second and third query parameters are not recognized because instead of separating the subsequent variables with an & that character gets converted into &. I could not find a good way to resolve this, so basically I just encoded the query string back to normal using html_entity_decode() and then slammed the parameters back into the $_GET array using parse_str().
There must be a better way! Anyone come across this before?
© Bradino or respective owner