base64_decode in php code example
Example 1: base64 decode in php
base64_decode('base64');
Example 2: php detect base64 encoding
function is_base64_encoded($data)
{
if (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data)) {
return TRUE;
} else {
return FALSE;
}
};
is_base64_encoded("iash21iawhdj98UH3");
is_base64_encoded("#iu3498r");
is_base64_encoded("asiudfh9w=8uihf");
is_base64_encoded("a398UIhnj43f/1!+sadfh3w84hduihhjw==");
Example 3: how do decode base64 php
base64_decode('base64-string-goes-here');
Example 4: base64 decode php
<?php
$str = 'R0ZHLCBBIGNvbXB1dGVyIFNjaWVuY2UgUG9ydGFsIEZvciBHZWVrcw';
echo base64_decode($str). "\n";
$str = 'MQ==';
echo base64_decode($str). "\n";
?>
Example 5: base64 decode php
GFG, A computer Science Portal For Geeks
1