Skip to content

Instantly share code, notes, and snippets.

@r37r0m0d3l
Created September 12, 2012 10:40
Show Gist options
  • Save r37r0m0d3l/3705860 to your computer and use it in GitHub Desktop.
Save r37r0m0d3l/3705860 to your computer and use it in GitHub Desktop.
Url variable encoding/decoding
<?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