In PHP the bindec()
function can be used to convert a binary number to decimal, but there is no error checking to test if the binary number string is valid. What happens is that something like bindec('1051');
returns 5 instead of an error.
Is there an efficient way to validate if the number is a binary string?