Re: hex2bin: E_WARNING is too much for odd string?

From: Date: Wed, 26 Jun 2013 20:59:05 +0000
Subject: Re: hex2bin: E_WARNING is too much for odd string?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-67908@lists.php.net to get a copy of this message
Hi Nikita, 2013/6/27 Nikita Popov <nikita.ppv@gmail.com> > Why is it easier? If you pass an odd length string to hex2bin you have > malformed input, which is usually a bug on the programmers side. Not having > a warning would make the issue harder to debug. It's good to have uniformed error handling. Therefore, E_WARNING for 'bad chars' is alternative. hex2bin('abcZ'); // E_WARNING for invalid char hex2bin('abc'); // E_WARNING for invalid length (Users can handle errors via custom error handler) or hex2bin('abcZ'); // return FALSE since there is invalid char hex2bin('abc'); // return FALSE since it has invalid length (Users should catch errors via their validation/error handling code) I think either raising error or returning false is OK, but it's not good have(mix) both for a function. It's not mandatory, though. It would be nice if there is error/exception handling guideline for module authors for uniform error/exception handling. IMHO. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#67908) next »