Created
September 12, 2012 10:40
-
-
Save r37r0m0d3l/3705860 to your computer and use it in GitHub Desktop.
Url variable encoding/decoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class url_var | |
{ | |
/** | |
* encode variable for url | |
* @param $var | |
* @return string | |
*/ | |
static function enc($var) | |
{ | |
return urlencode(base64_encode(serialize($var))); | |
} | |
/** | |
* decode variable from url | |
* @param $var | |
* @return mixed | |
*/ | |
static function dec($var) | |
{ | |
return unserialize(base64_decode(str_replace(' ', '+', urldecode($var)))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment