Hi Sherif,

The problem is that current code 'returns false for invalid hex' while it
'returns false and E_WARNING for invalid length'.

We may choose behavior for invalid inputs
 - return false always
 - return false and raise E_WARNING always

Mixing them up is not good, especially in the same function. IMHO. PHP has
enough inconsistency. We should try to remove inconsistency much as
possible. Besides the change will not break code as long as it is used as
it should be.

Considering the use case of hex2bin(), it will not handle external inputs
in most cases. Therefore, it's better to raise errors invalid inputs. Do
you prefer not to raise errors?

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to