Base64 encode and decode string in PHP

Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. Base64 encoding schemes are commonly used when there is a need to encode binary data that need to be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remain intact without modification during transport. Base64 is commonly used in a number of applications including email via MIME, and storing complex data in XML.
more on wiki..

function base64encode($text) {
	return strtr(base64_encode($text), '+/=', '-_,');
function base64decode($text) {
	return base64_decode(strtr($text, '-_,', '+/='));


echo 'base64:<b>'.base64encode('').'</b><br>';
echo 'plain:<b>'.base64decode('aHR0cDovL3dlYm5ldHNvZnQuZ3I,').'</b>';