function is_base64($str){
if($str === base64_encode(base64_decode($str))){
return true;
}
return false;
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
$str = 'VGhpcyBpcyBiYXNlNjQgZW5jb2RlIHN0cmluZw==';
if(is_base64($str)){
print base64_decode($str);
}