base64_encode — Encodes data with MIME base64
string base64_encode ( $string )
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original data.
$base64 = base64_encode($plainText);
$base64url = strtr($base64, '+/=', '-_,');
<?php $plainText = "aHR0cDovL3d3dy5waHBqYXZhc2NyaXB0LmNvbS8,"; $base64url = strtr($plainText, '-_,', '+/='); $base64 = base64_decode($base64url); echo $base64; ?>