base64_decode in PHP

Syntax of base64_decode

string base64_decode(string data)

Decodes data, which is base-64-encoded data, into a string (which may contain binary data). For more information on base-64 encoding, see RFC 2045

Example of base64_decode

$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);
This is an encoded string

More Example of base64_deocode

function base64url_encode($data, $pad = null) {
    $data = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
    if (!$pad) {
        $data = rtrim($data, '=');
    return $data;
function base64url_decode($data) {
    return base64_decode(str_replace(array('-', '_'), array('+', '/'), $data));

Leave a Comment