Indeed, when passing a parameter by URL, there are problems with certain values of the parameters. For example, if a text that we want to pass contains spaces, or symbols like “+”, we will not receive it correctly, unless we do something:
You have to encode the variable to URL format before putting it in the link. If you encode the variable, problematic characters (such as spaces) will be changed to ones that won’t give you problems. To do this you have to use the PHP function urlencode().
For example, take a look at this PHP code to pass a conflicting data pair per URL:
&var2=“>
Link with variable passing
This PHP code will generate the following HTML output, where we can see how the rare characters have been converted into codes that can be correctly passed through the URL:
The data can then be received on the page to which the link is directed, as usual:
echo $_GET;
echo $_GET;
The variables that are received already have the URL decoded, that is, with the characters as we want to receive them, not by the specific codes of the URL.
You can find information about this function on the PHP page itself: http://www.php.net/manual/en/function.urlencode.php