I have a string and want to test using PHP if it\'s a valid base64 encoded or not.
You can use this function:
function is_base64($s) { return (bool) preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $s); }