Home >Backend Development >PHP Tutorial >php base64_decode and base64_encode_PHP tutorial
php base64_decode and base64_encode
base64_decode
(PHP 4, PHP 5)
base64_decode - Base64 encoded MIME of decoded data
Description
string base64_decode (string $data[, boolean $strict=false])
Decode a BASE64 encoded data.
Parameters
Data
Encode data.
Strict
Returns FALSE if the input contains characters outside of a base64 alphabet.
Return value
Returns raw data or FALSE on failure. The data returned may be binary.
Modify
Release Notes
5.2.0 Strict Supplement
Example
Example #1 Example of base64_decode()
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);
?>
The above example will output:
This is an encoded string
base64_encode$str = 'This is an encoded string';
echo base64_encode($str);
?>
The above example will output:
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==