I have a string and want to test using PHP if it\'s a valid base64 encoded or not.
I am using this approach. It expects the last 2 characters to be ==
substr($buff, -2, 1) == '=' && substr($buff, -1, 1) == '=')
Update: I ended up doing another check if the one above fails base64_decode($buff, true)