I have a string and want to test using PHP if it\'s a valid base64 encoded or not.
This code should work, as the decode function returns FALSE if the string is not valid:
if (base64_decode($mystring, true)) { // is valid } else { // not valid }
You can read more about the base64_decode function in the documentation.