3 ms·
This doesn't look like the most professionally put together set of snippets I've ever seen. For example: function is_validemail($email) { $check = 0;
by oneeyedpigeon 11y ago
This doesn't look like the most professionally put together set of snippets I've ever seen. For example:
function is_validemail($email)
{
$check = 0;
if(filter_var($email,FILTER_VALIDATE_EMAIL))
{
$check = 1;
}
return $check;
}
is a long-winded way of doing:
function is_validemail($email)
{
return filter_var($email, FILTER_VALIDATE_EMAIL) ? 1 : 0;
}
- tuananh 11y agofrom teh function name, i would expect boolean as return type.
- sarciszewski 11y agoYeah, I would too.
- nkozyra 11y agoWell, it basically is due to type juggling.
- oneeyedpigeon 11y agoTo be fair, filter_var has a pretty screwy return type of its own but, yeah, if you're going to bother wrapping it, you might as well clean that up: return filter_var(...) !== FALSE; might do it ...