Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

base64_decode

Decodes a string from Base64.

Syntax

base64_decode(string $string, bool $strict = false): string|false

Parameters

ParameterTypeDescription
$stringstringThe encoded string.
$strictboolOptional. `true` returns `false` on stray characters.

Return value

string|falseThe original data, or `false`.

Examples

Decoding and strict checking:

<?php
 
echo base64_decode('SGVsbG8sIFBIUCE='), "\n";
var_dump(base64_decode('not base64!', true));

Output:

Hello, PHP!
bool(false)

Notes

Base64 is encoding, not encryption: anyone can decode the string.

See also

  • base64_encode — Encodes data as text made of ASCII letters and digits.
  • json_decode — Parses a JSON string.
  • bin2hex — Converts the bytes of a string to hexadecimal.

In the tutorial

  • HTTP requests and responses — How PHP receives a request and builds a response — the request method and address, headers, status codes, redirects and JSON responses.

Thanks for reading!

Donate to the site — we work hard for you.