Simple PHP base64 encode/decode url safe functions : How to

After searching through the php base64 comments I found the best way to safely encode and decode base64 url components

function base64_url_encode($input)
    return strtr(base64_encode($input), '+/=', '-_,');
function base64_url_decode($input)
    return base64_decode(strtr($input, '-_,', '+/='));

Refer gist for comments

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me or _justin_kelly


Leave a comment

Notify me of replies by email.