CKTIS / PHP
base64_decode()
Decode Base64 into bytes. In permissive mode characters outside the alphabet can be discarded, so use strict mode when malformed input matters.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
base64_decode(string $string, bool $strict = false): string|falseDecode Base64 into bytes. In permissive mode characters outside the alphabet can be discarded, so use strict mode when malformed input matters. Check false strictly because valid empty input decodes to an empty string. The bytes may not be printable. In PHP 8.4 strict mode still accepts whitespace and does not validate unused bits. Both "Y Q==" and "YR==" decode to "a" despite their noncanonical spelling.
Signature
base64_decode(string $string, bool $strict = false): string|false
Example output
["a",false,"","00ff"]
["a","a"]
Examples
<?php
$input = "YQ!==";
echo json_encode([base64_decode($input),base64_decode($input,true),base64_decode("",true),bin2hex(base64_decode("AP8=",true))]);
echo PHP_EOL,json_encode([base64_decode("Y Q==",true),base64_decode("YR==",true)]);
Result
["a",false,"","00ff"] ["a","a"]