How to encode a URL so that it can be passed along as a Get Variable in PHP
Because of the various symbols that a URL will and might contain, such as colons, slashes, question marks and equals, passing them along as a Get variable is not possible in their original format. Some encoding is needed to make this smooth transition possible.
As per usual you as a programmer are now faced with a choice. Either put together numerous string replaces, or instead using the predefined PHP function rawurlencode().
As the name indicates rawurlencode() converts a normal url into something encoded that can be passed along in environments where URL usually cause trouble. When included in a Get variable being one such instance. Here then is an example of this code in action:
$url = "http://www.example.com/index.php?page=260&id=22";
$encoded_url = rawurlencode($url);