base64_decode()
base64_decode() — Decodes data encoded with MIME base64.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
base64_decode(string $string, bool $strict = false): string|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $string | string | The encoded data. |
| $strict | bool | If the strict parameter is set to true then the base64_decode() function will return false if the input contains character from outside the base64 alphabet. Otherwise invalid characters will be silently discarded. |
Return value
Returns the decoded data or false on failure. The returned data may be binary.
Example
A runnable snippet:
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='; echo base64_decode($str);
Output:
This is an encoded string
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page base64_decode() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.